I am dealing with something mysterious or I am not thinking straight. Details are below, I held off on all usings-s, #include-s, etc. in favor of brevity. My code compiles fine.
Pseudo Code:
File: Constants.hpp
namespace TestConstants
{
const std::string TEST = "Test";
}
File: Program.cpp
#include "Constants.hpp"
void Program::Foo()
{
// do something with TestConstants::TEST here.
}
File: ProgramTest.cpp
#include "Program.hpp"
BOOST_FIXTURE_TEST_CASE(SomeTest, TestFixture)
{
Program p;
p.Foo();
}
Problem: When I run the test, TestConstants::TEST string is initialized to "" in Program::Foo(), while if I hit Ctrl+F5 the string constant contains the expected value and the code runs just fine. I verified this by debugging in both the cases. If I try accessing the string constant in the test itself, it is properly initialized but still empty when I get into Program::Foo().
I am using Visual Studio on a Windows 10 machine.
The test itself doesn't do any kind of set-up, let alone messing with constant strings. I am kind of clueless as to what I could be missing.