1 #include "gtest/gtest.h"
2 #include "unittest_macros.h"
12 TEST(OSDTest
, TestCentiNumber
)
14 //bool osdFormatCentiNumber(char *buff, int32_t centivalue, uint32_t scale, int maxDecimals, int maxScaledDecimals, int length);
15 char buf
[11] = "0123456789";
17 osdFormatCentiNumber(buf
, 12345, 1, 2, 3, 7, false);
18 std::cout
<< "'" << buf
<< "'" << std::endl
;
19 EXPECT_FALSE(strcmp(buf
, " 123.45"));
22 osdFormatCentiNumber(buf
, 12345, 1, 2, 2, 6, false);
23 std::cout
<< "'" << buf
<< "'" << std::endl
;
24 EXPECT_FALSE(strcmp(buf
, "123.45"));
27 osdFormatCentiNumber(buf
, 12345, 1, 2, 2, 5, false);
28 std::cout
<< "'" << buf
<< "'" << std::endl
;
29 EXPECT_FALSE(strcmp(buf
, "123.4"));
32 osdFormatCentiNumber(buf
, 12345, 1, 2, 2, 4, false);
33 std::cout
<< "'" << buf
<< "'" << std::endl
;
34 EXPECT_FALSE(strcmp(buf
, " 123")); // this should be causing #8769
37 osdFormatCentiNumber(buf
, 12345, 1, 2, 2, 3, false);
38 std::cout
<< "'" << buf
<< "'" << std::endl
;
39 EXPECT_FALSE(strcmp(buf
, "123"));
40 std::cout
<< "'" << buf
<< "'" << std::endl
;
43 osdFormatCentiNumber(buf
, -12345, 1, 2, 2, 8, false);
44 std::cout
<< "'" << buf
<< "'" << std::endl
;
45 EXPECT_FALSE(strcmp(buf
, " -123.45"));
50 osdFormatCentiNumber(buf
, -12345, 1, 2, 2, 7, false);
51 std::cout
<< "'" << buf
<< "'" << std::endl
;
52 EXPECT_FALSE(strcmp(buf
, "-123.45"));
55 osdFormatCentiNumber(buf
, -12345, 1, 2, 2, 6, false);
56 std::cout
<< "'" << buf
<< "'" << std::endl
;
57 EXPECT_FALSE(strcmp(buf
, "-123.4"));
60 osdFormatCentiNumber(buf
, -12345, 1, 2, 2, 5, false);
61 std::cout
<< "'" << buf
<< "'" << std::endl
;
62 EXPECT_FALSE(strcmp(buf
, " -123"));
65 osdFormatCentiNumber(buf
, -12345, 1, 2, 2, 4, false);
66 std::cout
<< "'" << buf
<< "'" << std::endl
;
67 EXPECT_FALSE(strcmp(buf
, "-123"));