### Question:
WXUtils { public static float getFloatByViewport(Object value, int viewport) { if (value == null) { return Float.NaN; } String temp = value.toString().trim(); if (Constants.Name.AUTO.equals(temp) || Constants.Name.UNDEFINED.equals(temp) || TextUtils.isEmpty(temp)) { WXLogUtils.e("Argument Warning ! value is " + temp + "And default Value:" + Float.NaN); return Float.NaN; } if (temp.endsWith("wx")) { try { return transferWx(temp, viewport); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } else { try { return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return Float.NaN; }  static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static int getNumberInt(Object value, int defaultValue); static final char PERCENT; }### Answer:
@Test public void testGetFloatWX() throws Exception { Float test_float = WXUtils.getFloatByViewport("100wx", TEST_VIEW_PORT); Float want = 100 * TEST_DENSITY * TEST_VIEW_PORT / TEST_SCREEN_WIDTH; assertEquals(test_float, want , 0.01); test_float = WXUtils.getFloatByViewport("100px", TEST_VIEW_PORT); want = 100F; assertEquals(test_float, want); test_float = WXUtils.getFloatByViewport("100.2", TEST_VIEW_PORT); want = 100.2F; assertEquals(test_float, want); test_float = WXUtils.getFloatByViewport(100.2F, TEST_VIEW_PORT); want = 100.2F; assertEquals(test_float, want, 0.0001); test_float = WXUtils.getFloatByViewport(100.2D, TEST_VIEW_PORT); want = 100.2F; assertEquals(test_float, want, 0.0001); test_float = WXUtils.getFloatByViewport("NaN", TEST_VIEW_PORT); want = Float.NaN; assertEquals(test_float, want); }