• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
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.
TEST(InfoLogTest,LogLengthCountsTerminator)19 TEST(InfoLogTest, LogLengthCountsTerminator)
20 {
21     InfoLog infoLog;
22     EXPECT_EQ(0u, infoLog.getLength());
23     infoLog << " ";
24 
25     // " \n\0" = 3 characters
26     EXPECT_EQ(3u, infoLog.getLength());
27 }
28 
29 // Tests that the log doesn't append newlines to an empty string
TEST(InfoLogTest,InfoLogEmptyString)30 TEST(InfoLogTest, InfoLogEmptyString)
31 {
32     InfoLog infoLog;
33     EXPECT_EQ(0u, infoLog.getLength());
34     infoLog << "";
35 
36     // "" = 3 characters
37     EXPECT_EQ(0u, infoLog.getLength());
38 }
39 
40 // Tests that newlines get appended to the info log properly.
TEST(InfoLogTest,AppendingNewline)41 TEST(InfoLogTest, AppendingNewline)
42 {
43     InfoLog infoLog;
44 
45     infoLog << "First" << 1 << 'x';
46     infoLog << "Second" << 2 << 'y';
47 
48     std::string expected = "First1x\nSecond2y\n";
49 
50     EXPECT_EQ(expected, infoLog.str());
51 }
52 
53 }  // namespace
54