ID
stringlengths
36
36
Language
stringclasses
1 value
Repository Name
stringclasses
13 values
File Name
stringlengths
2
48
File Path in Repository
stringlengths
11
111
File Path for Unit Test
stringlengths
13
116
Code
stringlengths
0
278k
Unit Test - (Ground Truth)
stringlengths
78
663k
Code Url
stringlengths
91
198
Test Code Url
stringlengths
93
203
Commit Hash
stringclasses
13 values
6869083b-75c0-4e08-a074-4c5908c73712
cpp
google/googletest
sample2
googletest/samples/sample2.cc
googletest/samples/sample2_unittest.cc
#include "sample2.h" #include <string.h> const char* MyString::CloneCString(const char* a_c_string) { if (a_c_string == nullptr) return nullptr; const size_t len = strlen(a_c_string); char* const clone = new char[len + 1]; memcpy(clone, a_c_string, len + 1); return clone; } void MyString::Set(const char* a_c_string) { const char* const temp = MyString::CloneCString(a_c_string); delete[] c_string_; c_string_ = temp; }
#include "sample2.h" #include "gtest/gtest.h" namespace { TEST(MyString, DefaultConstructor) { const MyString s; EXPECT_STREQ(nullptr, s.c_string()); EXPECT_EQ(0u, s.Length()); } const char kHelloString[] = "Hello, world!"; TEST(MyString, ConstructorFromCString) { const MyString s(kHelloString); EXPECT_EQ(0, strcmp(s.c_string(), kHelloString)); EXPECT_EQ(sizeof(kHelloString) / sizeof(kHelloString[0]) - 1, s.Length()); } TEST(MyString, CopyConstructor) { const MyString s1(kHelloString); const MyString s2 = s1; EXPECT_EQ(0, strcmp(s2.c_string(), kHelloString)); } TEST(MyString, Set) { MyString s; s.Set(kHelloString); EXPECT_EQ(0, strcmp(s.c_string(), kHelloString)); s.Set(s.c_string()); EXPECT_EQ(0, strcmp(s.c_string(), kHelloString)); s.Set(nullptr); EXPECT_STREQ(nullptr, s.c_string()); } }
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googletest/samples/sample2.cc
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googletest/samples/sample2_unittest.cc
a1e255a582377e1006bb88a408ac3f933ba7c916
05ca717a-710e-4112-add2-ca73d6c6071f
cpp
google/googletest
sample1
googletest/samples/sample1.cc
googletest/samples/sample1_unittest.cc
#include "sample1.h" int Factorial(int n) { int result = 1; for (int i = 1; i <= n; i++) { result *= i; } return result; } bool IsPrime(int n) { if (n <= 1) return false; if (n % 2 == 0) return n == 2; for (int i = 3;; i += 2) { if (i > n / i) break; if (n % i == 0) return false; } return true; }
#include "sample1.h" #include <limits.h> #include "gtest/gtest.h" namespace { TEST(FactorialTest, Negative) { EXPECT_EQ(1, Factorial(-5)); EXPECT_EQ(1, Factorial(-1)); EXPECT_GT(Factorial(-10), 0); } TEST(FactorialTest, Zero) { EXPECT_EQ(1, Factorial(0)); } TEST(FactorialTest, Positive) { EXPECT_EQ(1, Factorial(1)); EXPECT_EQ(2, Factorial(2)); EXPECT_EQ(6, Factorial(3)); EXPECT_EQ(40320, Factorial(8)); } TEST(IsPrimeTest, Negative) { EXPECT_FALSE(IsPrime(-1)); EXPECT_FALSE(IsPrime(-2)); EXPECT_FALSE(IsPrime(INT_MIN)); } TEST(IsPrimeTest, Trivial) { EXPECT_FALSE(IsPrime(0)); EXPECT_FALSE(IsPrime(1)); EXPECT_TRUE(IsPrime(2)); EXPECT_TRUE(IsPrime(3)); } TEST(IsPrimeTest, Positive) { EXPECT_FALSE(IsPrime(4)); EXPECT_TRUE(IsPrime(5)); EXPECT_FALSE(IsPrime(6)); EXPECT_TRUE(IsPrime(23)); } }
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googletest/samples/sample1.cc
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googletest/samples/sample1_unittest.cc
a1e255a582377e1006bb88a408ac3f933ba7c916
f5bec509-da94-4e49-bc7e-4fa9a774cd5b
cpp
google/googletest
sample4
googletest/samples/sample4.cc
googletest/samples/sample4_unittest.cc
#include "sample4.h" #include <stdio.h> int Counter::Increment() { return counter_++; } int Counter::Decrement() { if (counter_ == 0) { return counter_; } else { return counter_--; } } void Counter::Print() const { printf("%d", counter_); }
#include "sample4.h" #include "gtest/gtest.h" namespace { TEST(Counter, Increment) { Counter c; EXPECT_EQ(0, c.Decrement()); EXPECT_EQ(0, c.Increment()); EXPECT_EQ(1, c.Increment()); EXPECT_EQ(2, c.Increment()); EXPECT_EQ(3, c.Decrement()); } }
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googletest/samples/sample4.cc
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googletest/samples/sample4_unittest.cc
a1e255a582377e1006bb88a408ac3f933ba7c916
348ae442-7632-4acb-8891-c07bad76ebb1
cpp
google/googletest
gtest
googletest/src/gtest.cc
googletest/test/gtest_unittest.cc
"#include \"gtest/gtest.h\"\n#include <ctype.h>\n#include <stdarg.h>\n#include <stdio.h>\n#include <(...TRUNCATED)
"#include \"gtest/gtest.h\"\nTEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {\n(...TRUNCATED)
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googletest/src/gtest.cc
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googletest/test/gtest_unittest.cc
a1e255a582377e1006bb88a408ac3f933ba7c916
51c740cd-a235-4e14-b923-bec2dec16ca6
cpp
google/googletest
gtest_main
googletest/src/gtest_main.cc
googletest/test/gtest_main_unittest.cc
"#include <cstdio>\n#include \"gtest/gtest.h\"\n#if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ES(...TRUNCATED)
#include "gtest/gtest.h" namespace { TEST(GTestMainTest, ShouldSucceed) {} }
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googletest/src/gtest_main.cc
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googletest/test/gtest_main_unittest.cc
a1e255a582377e1006bb88a408ac3f933ba7c916
3e7cdd1d-f8d7-4034-8f45-062e29e11fb3
cpp
google/googletest
gtest-typed-test
googletest/src/gtest-typed-test.cc
googletest/test/gtest-typed-test_test.cc
"#include \"gtest/gtest-typed-test.h\"\n#include <set>\n#include <string>\n#include <vector>\n#inclu(...TRUNCATED)
"#include \"test/gtest-typed-test_test.h\"\n#include <set>\n#include <string>\n#include <type_traits(...TRUNCATED)
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googletest/src/gtest-typed-test.cc
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googletest/test/gtest-typed-test_test.cc
a1e255a582377e1006bb88a408ac3f933ba7c916
9d63bd8b-9c7a-4345-b260-6a298972320a
cpp
google/googletest
gmock-internal-utils
googlemock/src/gmock-internal-utils.cc
googlemock/test/gmock-internal-utils_test.cc
"#include \"gmock/internal/gmock-internal-utils.h\"\n#include <ctype.h>\n#include <array>\n#include (...TRUNCATED)
"#include \"gmock/internal/gmock-internal-utils.h\"\n#include <stdlib.h>\n#include <cstdint>\n#inclu(...TRUNCATED)
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googlemock/src/gmock-internal-utils.cc
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googlemock/test/gmock-internal-utils_test.cc
a1e255a582377e1006bb88a408ac3f933ba7c916
3c05ab69-2780-41fa-a46f-a2a323fc8a0d
cpp
google/googletest
gmock-cardinalities
googlemock/src/gmock-cardinalities.cc
googlemock/test/gmock-cardinalities_test.cc
"#include \"gmock/gmock-cardinalities.h\"\n#include <limits.h>\n#include <ostream> \n#include <sstr(...TRUNCATED)
"#include <ostream>\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest-spi.h\"\n#include \"gtest/gt(...TRUNCATED)
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googlemock/src/gmock-cardinalities.cc
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googlemock/test/gmock-cardinalities_test.cc
a1e255a582377e1006bb88a408ac3f933ba7c916
be659964-e353-481a-b2dd-23f6f1b2652a
cpp
google/googletest
gmock-spec-builders
googlemock/src/gmock-spec-builders.cc
googlemock/test/gmock-spec-builders_test.cc
"#include \"gmock/gmock-spec-builders.h\"\n#include <stdlib.h>\n#include <iostream> \n#include <map(...TRUNCATED)
"#include \"gmock/gmock-spec-builders.h\"\n#include <memory>\n#include <ostream> \n#include <sstrea(...TRUNCATED)
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googlemock/src/gmock-spec-builders.cc
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googlemock/test/gmock-spec-builders_test.cc
a1e255a582377e1006bb88a408ac3f933ba7c916
cfb250fc-4603-4bcf-a95d-0b15964ff56f
cpp
google/googletest
gmock
googlemock/src/gmock.cc
googlemock/test/gmock_test.cc
"#include \"gmock/gmock.h\"\n#include <string>\n#include \"gmock/internal/gmock-port.h\"\nGMOCK_DEFI(...TRUNCATED)
"#include \"gmock/gmock.h\"\n#include <string>\n#include \"gtest/gtest.h\"\n#include \"gtest/interna(...TRUNCATED)
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googlemock/src/gmock.cc
https://github.com/google/googletest/blob/a1e255a582377e1006bb88a408ac3f933ba7c916/googlemock/test/gmock_test.cc
a1e255a582377e1006bb88a408ac3f933ba7c916
README.md exists but content is empty.
Downloads last month
41