commence breakage
[inav.git] / src / test / unit / osd_unittest.cc
blobfd126c5c41a50132b382288f3b832a195a0f2e36
1 #include "gtest/gtest.h"
2 #include "unittest_macros.h"
4 #include <iostream>
5 #include <string>
7 extern "C" {
8 #include "io/osd.h"
9 };
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"));
21 memset(buf, 0, 11);
22 osdFormatCentiNumber(buf, 12345, 1, 2, 2, 6, false);
23 std::cout << "'" << buf << "'" << std::endl;
24 EXPECT_FALSE(strcmp(buf, "123.45"));
26 memset(buf, 0, 11);
27 osdFormatCentiNumber(buf, 12345, 1, 2, 2, 5, false);
28 std::cout << "'" << buf << "'" << std::endl;
29 EXPECT_FALSE(strcmp(buf, "123.4"));
31 memset(buf, 0, 11);
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
36 memset(buf, 0, 11);
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;
42 memset(buf, 0, 11);
43 osdFormatCentiNumber(buf, -12345, 1, 2, 2, 8, false);
44 std::cout << "'" << buf << "'" << std::endl;
45 EXPECT_FALSE(strcmp(buf, " -123.45"));
49 memset(buf, 0, 11);
50 osdFormatCentiNumber(buf, -12345, 1, 2, 2, 7, false);
51 std::cout << "'" << buf << "'" << std::endl;
52 EXPECT_FALSE(strcmp(buf, "-123.45"));
54 memset(buf, 0, 11);
55 osdFormatCentiNumber(buf, -12345, 1, 2, 2, 6, false);
56 std::cout << "'" << buf << "'" << std::endl;
57 EXPECT_FALSE(strcmp(buf, "-123.4"));
59 memset(buf, 0, 11);
60 osdFormatCentiNumber(buf, -12345, 1, 2, 2, 5, false);
61 std::cout << "'" << buf << "'" << std::endl;
62 EXPECT_FALSE(strcmp(buf, " -123"));
64 memset(buf, 0, 11);
65 osdFormatCentiNumber(buf, -12345, 1, 2, 2, 4, false);
66 std::cout << "'" << buf << "'" << std::endl;
67 EXPECT_FALSE(strcmp(buf, "-123"));
69 EXPECT_EQ(1, 1);