Skip to content

Commit

Permalink
Open curly braces should start new lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
antiagainst committed Mar 23, 2016
1 parent af6e729 commit 87302da
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 23 deletions.
3 changes: 2 additions & 1 deletion StandAlone/DefaultResourceLimits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ const TBuiltInResource DefaultTBuiltInResource = {
/* .generalConstantMatrixVectorIndexing = */ 1,
}};

std::string GetDefaultTBuiltInResourceString() {
std::string GetDefaultTBuiltInResourceString()
{
std::ostringstream ostream;

ostream << "MaxLights " << DefaultTBuiltInResource.maxLights << "\n"
Expand Down
3 changes: 2 additions & 1 deletion gtests/AST.FromFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ namespace {

using CompileToAstTest = GlslangTest<::testing::TestWithParam<std::string>>;

TEST_P(CompileToAstTest, FromFile) {
TEST_P(CompileToAstTest, FromFile)
{
loadFileCompileAndCheck(GLSLANG_TEST_DIRECTORY, GetParam(),
Semantics::OpenGL, Target::AST);
}
Expand Down
3 changes: 2 additions & 1 deletion gtests/BuiltInResource.FromFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ namespace {

using DefaultResourceTest = GlslangTest<::testing::Test>;

TEST_F(DefaultResourceTest, FromFile) {
TEST_F(DefaultResourceTest, FromFile)
{
const std::string path = GLSLANG_TEST_DIRECTORY "/baseResults/test.conf";
std::string expectedConfig;
tryLoadFile(path, "expected resource limit", &expectedConfig);
Expand Down
12 changes: 8 additions & 4 deletions gtests/Initializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ namespace glslangtest {
// gets fixed.
class GlslangInitializer {
public:
GlslangInitializer() : lastMessages(EShMsgDefault) {
GlslangInitializer() : lastMessages(EShMsgDefault)
{
glslang::InitializeProcess();
}

Expand All @@ -64,14 +65,16 @@ class GlslangInitializer {
class InitializationToken {
public:
InitializationToken() : initializer(nullptr) {}
~InitializationToken() {
~InitializationToken()
{
if (initializer) {
initializer->release();
}
}

InitializationToken(InitializationToken&& other)
: initializer(other.initializer) {
: initializer(other.initializer)
{
other.initializer = nullptr;
}

Expand All @@ -89,7 +92,8 @@ class GlslangInitializer {
// exclusive until the Initialization Token has been destroyed.
// Re-initializes glsl state iff the previous messages and the current
// messages are incompatible.
InitializationToken acquire(EShMessages new_messages) {
InitializationToken acquire(EShMessages new_messages)
{
stateLock.lock();

if ((lastMessages ^ new_messages) &
Expand Down
3 changes: 2 additions & 1 deletion gtests/Pp.FromFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ namespace {

using PreprocessingTest = GlslangTest<::testing::TestWithParam<std::string>>;

TEST_P(PreprocessingTest, FromFile) {
TEST_P(PreprocessingTest, FromFile)
{
loadFilePreprocessAndCheck(GLSLANG_TEST_DIRECTORY, GetParam());
}

Expand Down
6 changes: 4 additions & 2 deletions gtests/Spv.FromFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ using VulkanSemantics = GlslangTest<::testing::TestWithParam<std::string>>;

// Compiling GLSL to SPIR-V under Vulkan semantics. Expected to successfully
// generate SPIR-V.
TEST_P(CompileToSpirvTest, FromFile) {
TEST_P(CompileToSpirvTest, FromFile)
{
loadFileCompileAndCheck(GLSLANG_TEST_DIRECTORY, GetParam(),
Semantics::Vulkan, Target::Spirv);
}

// GLSL-level Vulkan semantics test. Expected to error out before generating
// SPIR-V.
TEST_P(VulkanSemantics, FromFile) {
TEST_P(VulkanSemantics, FromFile)
{
loadFileCompileAndCheck(GLSLANG_TEST_DIRECTORY, GetParam(),
Semantics::Vulkan, Target::Spirv);
}
Expand Down
18 changes: 12 additions & 6 deletions gtests/TestFixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@
namespace glslangtest {

std::string FileNameAsCustomTestName(
const ::testing::TestParamInfo<std::string>& info) {
const ::testing::TestParamInfo<std::string>& info)
{
std::string name = info.param;
// A valid test case suffix cannot have '.' and '-' inside.
std::replace(name.begin(), name.end(), '.', '_');
std::replace(name.begin(), name.end(), '-', '_');
return name;
}

EShLanguage GetGlslLanguageForStage(const std::string& stage) {
EShLanguage GetGlslLanguageForStage(const std::string& stage)
{
if (stage == "vert") {
return EShLangVertex;
} else if (stage == "tesc") {
Expand All @@ -65,7 +67,8 @@ EShLanguage GetGlslLanguageForStage(const std::string& stage) {
}

EShMessages GetSpirvMessageOptionsForSemanticsAndTarget(Semantics semantics,
Target target) {
Target target)
{
EShMessages result = EShMsgDefault;

switch (target) {
Expand All @@ -88,7 +91,8 @@ EShMessages GetSpirvMessageOptionsForSemanticsAndTarget(Semantics semantics,
return result;
}

std::pair<bool, std::string> ReadFile(const std::string& path) {
std::pair<bool, std::string> ReadFile(const std::string& path)
{
std::ifstream fstream(path, std::ios::in);
if (fstream) {
std::string contents;
Expand All @@ -102,15 +106,17 @@ std::pair<bool, std::string> ReadFile(const std::string& path) {
return std::make_pair(false, "");
}

bool WriteFile(const std::string& path, const std::string& contents) {
bool WriteFile(const std::string& path, const std::string& contents)
{
std::ofstream fstream(path, std::ios::out);
if (!fstream) return false;
fstream << contents;
fstream.flush();
return true;
}

std::string GetSuffix(const std::string& name) {
std::string GetSuffix(const std::string& name)
{
const size_t pos = name.rfind('.');
return (pos == std::string::npos) ? "" : name.substr(name.rfind('.') + 1);
}
Expand Down
18 changes: 12 additions & 6 deletions gtests/TestFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ class GlslangTest : public GT {
// Tries to load the contents from the file at the given |path|. On success,
// writes the contents into |contents|. On failure, errors out.
void tryLoadFile(const std::string& path, const std::string& tag,
std::string* contents) {
std::string* contents)
{
bool fileReadOk;
std::tie(fileReadOk, *contents) = ReadFile(path);
ASSERT_TRUE(fileReadOk) << "Cannot open " << tag << " file: " << path;
Expand All @@ -127,7 +128,8 @@ class GlslangTest : public GT {
// |real| to the given file named as |fname| if update mode is on.
void checkEqAndUpdateIfRequested(const std::string& expected,
const std::string& real,
const std::string& fname) {
const std::string& fname)
{
// In order to output the message we want under proper circumstances, we
// need the following operator<< stuff.
EXPECT_EQ(expected, real)
Expand Down Expand Up @@ -164,7 +166,8 @@ class GlslangTest : public GT {
// the result and returns disassembly text.
GlslangResult compileGlsl(const std::string& source,
const std::string& stage, Semantics semantics,
Target target) {
Target target)
{
const char* shaderStrings = source.data();
const int shaderLengths = static_cast<int>(source.size());
const EShLanguage language = GetGlslLanguageForStage(stage);
Expand Down Expand Up @@ -203,7 +206,8 @@ class GlslangTest : public GT {

void loadFileCompileAndCheck(const std::string& testDir,
const std::string& testName,
Semantics semantics, Target target) {
Semantics semantics, Target target)
{
const std::string inputFname = testDir + "/" + testName;
const std::string expectedOutputFname =
testDir + "/baseResults/" + testName + ".out";
Expand Down Expand Up @@ -242,7 +246,8 @@ class GlslangTest : public GT {
// preprocessed shader, and warning messages. Otherwise, returns false, an
// empty string, and error messages.
std::tuple<bool, std::string, std::string> preprocessGlsl(
const std::string& source) {
const std::string& source)
{
const char* shaderStrings = source.data();
const int shaderLengths = static_cast<int>(source.size());

Expand All @@ -264,7 +269,8 @@ class GlslangTest : public GT {
}

void loadFilePreprocessAndCheck(const std::string& testDir,
const std::string& testName) {
const std::string& testName)
{
const std::string inputFname = testDir + "/" + testName;
const std::string expectedOutputFname =
testDir + "/baseResults/" + testName + ".out";
Expand Down
3 changes: 2 additions & 1 deletion gtests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
#include "Initializer.h"
#include "Settings.h"

int main(int argc, char** argv) {
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);

std::unique_ptr<glslangtest::GlslangInitializer> initializer(
Expand Down

0 comments on commit 87302da

Please sign in to comment.