test_tb_dimension.cpp 940 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // ================================================================================
  2. // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås ==
  3. // == See tb_core.h for more information. ==
  4. // ================================================================================
  5. #include "tb_test.h"
  6. #include "tb_dimension.h"
  7. #include "tb_core.h"
  8. #ifdef TB_UNIT_TESTING
  9. using namespace tb;
  10. TB_TEST_GROUP(tb_dimension_converter)
  11. {
  12. TBDimensionConverter dim_conv;
  13. TB_TEST(Init)
  14. {
  15. dim_conv.SetDPI(100, 200);
  16. }
  17. TB_TEST(set_from_string_unspecified)
  18. {
  19. int px = dim_conv.GetPxFromString("50", 0);
  20. TB_VERIFY(px == 50 * 2);
  21. }
  22. TB_TEST(set_from_string_px)
  23. {
  24. int px = dim_conv.GetPxFromString("50px", 0);
  25. TB_VERIFY(px == 50);
  26. }
  27. TB_TEST(set_from_string_dp)
  28. {
  29. int px = dim_conv.GetPxFromString("50dp", 0);
  30. TB_VERIFY(px == 50 * 2);
  31. }
  32. }
  33. #endif // TB_UNIT_TESTING