1. Matt Oswald
  2. xUnit++

Commits

Matt Oswald  committed 1fd6d26

even I forget that Same/NotSame mean 'same object' not 'same values'

  • Participants
  • Parent commits 5342884
  • Branches default

Comments (0)

Files changed (4)

File .build/build.props

View file
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
       <MinimalRebuild>false</MinimalRebuild>
     </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
   </ItemDefinitionGroup>
   <ItemGroup />
-</Project>
+</Project>

File Tests/UnitTests/Assert.NotSame.cpp

View file
 SUITE(AssertNotSame)
 {
 
-FACT(NotSameSuccess)
+struct NotSameFixture
 {
-    int x = 2;
-    int y = 2;
+    NotSameFixture()
+        : obj(2)
+        , different(3)
+    {
+    }
 
-    Assert.NotSame(x, y);
+    int obj;
+    int different;
+};
+
+FACT_FIXTURE(NotSameSuccess, NotSameFixture)
+{
+    Assert.NotSame(obj, different);
 }
 
-FACT(NotSameForPointersSuccess)
+FACT_FIXTURE(NotSameForPointersSuccess, NotSameFixture)
 {
-    int x = 2;
-    int y = 2;
-
-    Assert.NotSame(&x, &y);
+    Assert.NotSame(&obj, &different);
 }
 
-FACT(NotSameAssertsOnFailure)
+FACT_FIXTURE(NotSameAssertsOnFailure, NotSameFixture)
 {
-    int x;
-
-    Assert.Throws<xUnitAssert>([=]() { Assert.NotSame(x, x); });
+    Assert.Throws<xUnitAssert>([&]() { Assert.NotSame(obj, obj); });
 }
 
-FACT(NotSameForPointersAssertsOnFailure)
+FACT_FIXTURE(NotSameForPointersAssertsOnFailure, NotSameFixture)
 {
-    int x;
-
-    Assert.Throws<xUnitAssert>([=]() { Assert.NotSame(&x, &x); });
+    Assert.Throws<xUnitAssert>([&]() { Assert.NotSame(&obj, &obj); });
 }
 
-FACT(NotSameAppendsUserMessage)
+FACT_FIXTURE(NotSameAppendsUserMessage, NotSameFixture)
 {
     static const std::string msg = "xUnit++";
 
-    int x;
-
-    auto assert = Assert.Throws<xUnitAssert>([&]() { Assert.NotSame(x, x) << msg; });
+    auto assert = Assert.Throws<xUnitAssert>([&]() { Assert.NotSame(obj, obj) << msg; });
 
     Assert.Contains(assert.what(), msg.c_str());
 }

File Tests/UnitTests/Assert.Same.cpp

View file
 {
     static const std::string msg = "xUnit++";
 
-    auto assert = Assert.Throws<xUnitAssert>([]() { Assert.Same(0, 1) << msg; });
+    int x = 0;
+    int y = 0;
+
+    auto assert = Assert.Throws<xUnitAssert>([=]() { Assert.Same(x, y) << msg; });
 
     Assert.Contains(assert.what(), msg.c_str());
 }

File notes.txt

View file
 General
 -------
 finish unit testing the lib
-    - ensure tests are actually ran
-        - will require new project
     - ensure output formats
     - several tests (look at Theory.cpp) do not actually assert anything happened
-check Release builds for warnings (and failing tests)
-can runner be made configuration agnostic? (ie, can debug runner load release tests, and vice versa? (and what about x64?)
 redo include structure
 vsix project needs embedded eula and license
 need license for whole project