Jamie Madill | 71c3b2c | 2015-05-07 11:49:20 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2015 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | // Unit tests for Program and related classes. |
| 7 | // |
| 8 | |
| 9 | #include <gtest/gtest.h> |
| 10 | |
Jamie Madill | 71c3b2c | 2015-05-07 11:49:20 -0400 | [diff] [blame] | 11 | #include "libANGLE/Program.h" |
| 12 | |
| 13 | using namespace gl; |
| 14 | |
| 15 | namespace |
| 16 | { |
| 17 | |
| 18 | // Tests that the log length properly counts the terminating \0. |
| 19 | TEST(InfoLogTest, LogLengthCountsTerminator) |
| 20 | { |
| 21 | InfoLog infoLog; |
| 22 | EXPECT_EQ(0u, infoLog.getLength()); |
Jamie Madill | f611316 | 2015-05-07 11:49:21 -0400 | [diff] [blame] | 23 | infoLog << " "; |
Jamie Madill | 71c3b2c | 2015-05-07 11:49:20 -0400 | [diff] [blame] | 24 | |
| 25 | // " \n\0" = 3 characters |
| 26 | EXPECT_EQ(3u, infoLog.getLength()); |
| 27 | } |
| 28 | |
Jamie Madill | f611316 | 2015-05-07 11:49:21 -0400 | [diff] [blame] | 29 | // Tests that newlines get appended to the info log properly. |
| 30 | TEST(InfoLogTest, AppendingNewline) |
| 31 | { |
| 32 | InfoLog infoLog; |
| 33 | |
| 34 | infoLog << "First" << 1 << 'x'; |
| 35 | infoLog << "Second" << 2 << 'y'; |
| 36 | |
| 37 | std::string expected = "First1x\nSecond2y\n"; |
| 38 | |
| 39 | EXPECT_EQ(expected, infoLog.str()); |
| 40 | } |
| 41 | |
Jamie Madill | 71c3b2c | 2015-05-07 11:49:20 -0400 | [diff] [blame] | 42 | } // namespace |