Edit

kc3-lang/angle/src/libANGLE/Program_unittest.cpp

Branch :

  • Show log

    Commit

  • Author : Jonah Ryan-Davis
    Date : 2021-03-30 15:57:02
    Hash : 46769f82
    Message : Don't append newline to empty InfoLog stream. Users were seeing different behavior when querying GL_INFO_LOG_LENGTH with ANGLE because ANGLE was always adding a newline to the InfoLog. Bug: chromium:1191293 Change-Id: I50f56326871cdd2f6614f5b1622257845721244c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2795164 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>

  • src/libANGLE/Program_unittest.cpp
  • //
    // Copyright 2015 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    // Unit tests for Program and related classes.
    //
    
    #include <gtest/gtest.h>
    
    #include "libANGLE/Program.h"
    
    using namespace gl;
    
    namespace
    {
    
    // Tests that the log length properly counts the terminating \0.
    TEST(InfoLogTest, LogLengthCountsTerminator)
    {
        InfoLog infoLog;
        EXPECT_EQ(0u, infoLog.getLength());
        infoLog << " ";
    
        // " \n\0" = 3 characters
        EXPECT_EQ(3u, infoLog.getLength());
    }
    
    // Tests that the log doesn't append newlines to an empty string
    TEST(InfoLogTest, InfoLogEmptyString)
    {
        InfoLog infoLog;
        EXPECT_EQ(0u, infoLog.getLength());
        infoLog << "";
    
        // "" = 3 characters
        EXPECT_EQ(0u, infoLog.getLength());
    }
    
    // Tests that newlines get appended to the info log properly.
    TEST(InfoLogTest, AppendingNewline)
    {
        InfoLog infoLog;
    
        infoLog << "First" << 1 << 'x';
        infoLog << "Second" << 2 << 'y';
    
        std::string expected = "First1x\nSecond2y\n";
    
        EXPECT_EQ(expected, infoLog.str());
    }
    
    }  // namespace