Skip to content

Commit

Permalink
bugfix: struct types weren't handled properly in typed tests
Browse files Browse the repository at this point in the history
this references #13
  • Loading branch information
Christian Soltenborn committed Jan 5, 2016
1 parent 0c937c6 commit ff343f1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ private TestCaseDescriptor CreateDescriptor(string suiteLine, string testCaseLin
{
typeParam = split[1];
typeParam = typeParam.Replace("class ", "");
typeParam = typeParam.Replace("struct ", "");
}

split = testCaseLine.Split(new[] { GoogleTestConstants.ParameterizedTestMarker }, StringSplitOptions.RemoveEmptyEntries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public void GetTestsFromExecutable_StaticallyLinkedX86Executable_FindsTestsWitLo
}

[TestMethod]
public void GetTestsFromExecutable_StaticallyLinkedX64Executable_FindsTestsWithLocation()
public void GetTestsFromExecutable_SampleTests_FindsTestsWithLocation()
{
FindStaticallyLinkedTests(X64StaticallyLinkedTests);
FindSampleTests(SampleTests);
}

[TestMethod]
Expand Down Expand Up @@ -227,23 +227,38 @@ private void AssertIsGoogleTestExecutable(string executable, bool isGoogleTestEx
new GoogleTestDiscoverer(TestEnvironment).IsGoogleTestExecutable(executable, regex));
}

private void FindStaticallyLinkedTests(string location)
{
GoogleTestDiscoverer discoverer = new GoogleTestDiscoverer(TestEnvironment);
IList<TestCase> testCases = discoverer.GetTestsFromExecutable(location);
private void FindSampleTests(string location)
{
GoogleTestDiscoverer discoverer = new GoogleTestDiscoverer(TestEnvironment);
IList<TestCase> testCases = discoverer.GetTestsFromExecutable(location);

Assert.AreEqual(2, testCases.Count);
Assert.AreEqual(49, testCases.Count);

Assert.AreEqual("FooTest.MethodBarDoesAbc", testCases[0].DisplayName);
Assert.AreEqual(@"c:\prod\gtest-1.7.0\staticallylinkedgoogletests\main.cpp", testCases[0].CodeFilePath);
Assert.AreEqual(36, testCases[0].LineNumber);
TestCase testCase =
testCases.Single(tc => tc.FullyQualifiedName == "Arr/TypeParameterizedTests/1.CanDefeatMath");

Assert.AreEqual("FooTest.DoesXyz", testCases[1].DisplayName);
Assert.AreEqual(@"c:\prod\gtest-1.7.0\staticallylinkedgoogletests\main.cpp", testCases[1].CodeFilePath);
Assert.AreEqual(45, testCases[1].LineNumber);
}
Assert.AreEqual("Arr/TypeParameterizedTests/1.CanDefeatMath<MyStrangeArray>", testCase.DisplayName);
Assert.AreEqual(@"c:\users\cso\git\googletestadapter\samplegoogletesttests\tests\typeparameterizedtests.cpp", testCase.CodeFilePath);
Assert.AreEqual(44, testCase.LineNumber);
}

private void FindStaticallyLinkedTests(string location)
{
GoogleTestDiscoverer discoverer = new GoogleTestDiscoverer(TestEnvironment);
IList<TestCase> testCases = discoverer.GetTestsFromExecutable(location);

Assert.AreEqual(2, testCases.Count);

Assert.AreEqual("FooTest.MethodBarDoesAbc", testCases[0].DisplayName);
Assert.AreEqual(@"c:\prod\gtest-1.7.0\staticallylinkedgoogletests\main.cpp", testCases[0].CodeFilePath);
Assert.AreEqual(36, testCases[0].LineNumber);

Assert.AreEqual("FooTest.DoesXyz", testCases[1].DisplayName);
Assert.AreEqual(@"c:\prod\gtest-1.7.0\staticallylinkedgoogletests\main.cpp", testCases[1].CodeFilePath);
Assert.AreEqual(45, testCases[1].LineNumber);
}

private void FindExternallyLinkedTests(string location)
private void FindExternallyLinkedTests(string location)
{
GoogleTestDiscoverer discoverer = new GoogleTestDiscoverer(TestEnvironment);
IList<TestCase> testCases = discoverer.GetTestsFromExecutable(location);
Expand Down
4 changes: 2 additions & 2 deletions SampleGoogleTestTests/Tests/TypeParameterizedTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#include <array>
#include <list>

class MyStrangeArray : public std::array<int, 3>
struct MyStrangeArray : public std::array<int, 3>
{
public: MyStrangeArray(std::initializer_list<int> init) : array({ 3,2,1 }) {}
MyStrangeArray(std::initializer_list<int> init) : array({ 3,2,1 }) {}
};


Expand Down

0 comments on commit ff343f1

Please sign in to comment.