// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include #include namespace storage { TEST(HtmlTableTest, testPercentageColumn) { // With total hardcoded to 100 { HtmlTable table("disk"); PercentageColumn perc("fillrate", 100); perc.addColorLimit(70, Column::LIGHT_GREEN); perc.addColorLimit(85, Column::LIGHT_YELLOW); perc.addColorLimit(100, Column::LIGHT_RED); table.addColumn(perc); table.addRow(0); table.addRow(1); table.addRow(2); perc[0] = 30; perc[1] = 80; perc[2] = 100; std::ostringstream ost; table.print(ost); std::string expected( "\n" "\n" "\n" "\n" "\n" "
diskfillrate
030.00 %
180.00 %
2100.00 %
\n"); EXPECT_EQ(expected, ost.str()); } // With automatically gathered total { HtmlTable table("disk"); PercentageColumn perc("fillrate"); table.addColumn(perc); table.addRow(0); table.addRow(1); table.addRow(2); perc[0] = 30; perc[1] = 80; perc[2] = 100; std::ostringstream ost; table.print(ost); std::string expected( "\n" "\n" "\n" "\n" "\n" "
diskfillrate
014.29 %
138.10 %
247.62 %
\n"); EXPECT_EQ(expected, ost.str()); } } TEST(HtmlTableTest, testByteSizeColumn) { { HtmlTable table("disk"); ByteSizeColumn size("size"); table.addColumn(size); table.addRow(0); table.addRow(1); table.addRow(2); // Biggest value enforce the denomination size[0] = 42123; size[1] = 124123151; size[2] = 6131231; std::ostringstream ost; table.print(ost); std::string expected( "\n" "\n" "\n" "\n" "\n" "
disksize
00 MB
1118 MB
25 MB
\n"); EXPECT_EQ(expected, ost.str()); } } } // storage