1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #define LOG_TAG "audio_utils_errorlog_tests"
- #include <audio_utils/SimpleLog.h>
- #include <gtest/gtest.h>
- #include <iostream>
- #include <log/log.h>
- using namespace android;
- static size_t countNewLines(const std::string &s) {
- return std::count(s.begin(), s.end(), '\n');
- }
- TEST(audio_utils_simplelog, basic) {
- auto slog = std::make_unique<SimpleLog>();
- const int64_t oneSecond = 1000000000;
- EXPECT_EQ((size_t)0, countNewLines(slog->dumpToString()));
- const int nine = 9;
- slog->log("Hello %d", nine);
- slog->log("World");
- slog->logs(-1 , std::string("ABC"));
-
- EXPECT_EQ((size_t)3, countNewLines(slog->dumpToString()));
-
- slog->log(oneSecond , "Hello World %d", 10);
- slog->log(oneSecond * 2 , "%s", "Goodbye");
- EXPECT_EQ((size_t)5, countNewLines(slog->dumpToString()));
-
- EXPECT_EQ((size_t)1, countNewLines(slog->dumpToString("" , 1 )));
-
- EXPECT_EQ((size_t)5, countNewLines(
- slog->dumpToString("" , 0 , oneSecond )));
-
- EXPECT_EQ((size_t)4, countNewLines(
- slog->dumpToString("" , 0 , oneSecond * 2 )));
-
- EXPECT_EQ((size_t)3, countNewLines(
- slog->dumpToString("" , 0 , oneSecond * 2 + 1 )));
- std::cout << slog->dumpToString() << std::flush;
- slog->dump(0 , " ");
-
-
-
- }
|