aboutsummaryrefslogtreecommitdiffstats
path: root/gtest/samples
diff options
context:
space:
mode:
authorJeff Davidson <jpd@google.com>2015-01-20 10:18:05 -0800
committerJeff Davidson <jpd@google.com>2015-01-20 10:18:05 -0800
commit0ddac1f3791efefb2cffdb425f0c600feb7a47e6 (patch)
treeefeab8fb69198186f1dabfe43d341c7b70c9c5f1 /gtest/samples
parent77a6b2f4cdd580d57630f079db1d908d7fd90a54 (diff)
downloadexternal_protobuf-0ddac1f3791efefb2cffdb425f0c600feb7a47e6.zip
external_protobuf-0ddac1f3791efefb2cffdb425f0c600feb7a47e6.tar.gz
external_protobuf-0ddac1f3791efefb2cffdb425f0c600feb7a47e6.tar.bz2
Update protobuf's gtest to expected version.
Generated by running: rm -rf gtest ./autogen.sh ./configure Change-Id: I5d9c0bea09dd9d3e4d7d4442dd8222011f5c522a
Diffstat (limited to 'gtest/samples')
-rw-r--r--gtest/samples/prime_tables.h3
-rw-r--r--gtest/samples/sample10_unittest.cc6
-rw-r--r--gtest/samples/sample2.cc14
-rw-r--r--gtest/samples/sample2.h12
-rw-r--r--gtest/samples/sample2_unittest.cc2
-rw-r--r--gtest/samples/sample3-inl.h50
-rw-r--r--gtest/samples/sample3_unittest.cc6
-rw-r--r--gtest/samples/sample5_unittest.cc8
-rw-r--r--gtest/samples/sample7_unittest.cc12
-rw-r--r--gtest/samples/sample8_unittest.cc12
-rw-r--r--gtest/samples/sample9_unittest.cc2
11 files changed, 65 insertions, 62 deletions
diff --git a/gtest/samples/prime_tables.h b/gtest/samples/prime_tables.h
index 236e84c..92ce16a 100644
--- a/gtest/samples/prime_tables.h
+++ b/gtest/samples/prime_tables.h
@@ -115,6 +115,9 @@ class PreCalculatedPrimeTable : public PrimeTable {
const int is_prime_size_;
bool* const is_prime_;
+
+ // Disables compiler warning "assignment operator could not be generated."
+ void operator=(const PreCalculatedPrimeTable& rhs);
};
#endif // GTEST_SAMPLES_PRIME_TABLES_H_
diff --git a/gtest/samples/sample10_unittest.cc b/gtest/samples/sample10_unittest.cc
index 703ec6e..3ad6fd6 100644
--- a/gtest/samples/sample10_unittest.cc
+++ b/gtest/samples/sample10_unittest.cc
@@ -58,7 +58,7 @@ class Water {
return malloc(allocation_size);
}
- void operator delete(void* block, size_t allocation_size) {
+ void operator delete(void* block, size_t /* allocation_size */) {
allocated_--;
free(block);
}
@@ -78,12 +78,12 @@ int Water::allocated_ = 0;
class LeakChecker : public EmptyTestEventListener {
private:
// Called before a test starts.
- virtual void OnTestStart(const TestInfo& test_info) {
+ virtual void OnTestStart(const TestInfo& /* test_info */) {
initially_allocated_ = Water::allocated();
}
// Called after a test ends.
- virtual void OnTestEnd(const TestInfo& test_info) {
+ virtual void OnTestEnd(const TestInfo& /* test_info */) {
int difference = Water::allocated() - initially_allocated_;
// You can generate a failure in any event handler except
diff --git a/gtest/samples/sample2.cc b/gtest/samples/sample2.cc
index 53857c0..5f763b9 100644
--- a/gtest/samples/sample2.cc
+++ b/gtest/samples/sample2.cc
@@ -36,21 +36,21 @@
#include <string.h>
// Clones a 0-terminated C string, allocating memory using new.
-const char * MyString::CloneCString(const char * c_string) {
- if (c_string == NULL) return NULL;
+const char* MyString::CloneCString(const char* a_c_string) {
+ if (a_c_string == NULL) return NULL;
- const size_t len = strlen(c_string);
- char * const clone = new char[ len + 1 ];
- memcpy(clone, c_string, len + 1);
+ const size_t len = strlen(a_c_string);
+ char* const clone = new char[ len + 1 ];
+ memcpy(clone, a_c_string, len + 1);
return clone;
}
// Sets the 0-terminated C string this MyString object
// represents.
-void MyString::Set(const char * c_string) {
+void MyString::Set(const char* a_c_string) {
// Makes sure this works when c_string == c_string_
- const char * const temp = MyString::CloneCString(c_string);
+ const char* const temp = MyString::CloneCString(a_c_string);
delete[] c_string_;
c_string_ = temp;
}
diff --git a/gtest/samples/sample2.h b/gtest/samples/sample2.h
index c5f3b8c..5b57e60 100644
--- a/gtest/samples/sample2.h
+++ b/gtest/samples/sample2.h
@@ -40,13 +40,13 @@
// A simple string class.
class MyString {
private:
- const char * c_string_;
+ const char* c_string_;
const MyString& operator=(const MyString& rhs);
public:
// Clones a 0-terminated C string, allocating memory using new.
- static const char * CloneCString(const char * c_string);
+ static const char* CloneCString(const char* a_c_string);
////////////////////////////////////////////////////////////
//
@@ -56,8 +56,8 @@ class MyString {
MyString() : c_string_(NULL) {}
// Constructs a MyString by cloning a 0-terminated C string.
- explicit MyString(const char * c_string) : c_string_(NULL) {
- Set(c_string);
+ explicit MyString(const char* a_c_string) : c_string_(NULL) {
+ Set(a_c_string);
}
// Copy c'tor
@@ -72,14 +72,14 @@ class MyString {
~MyString() { delete[] c_string_; }
// Gets the 0-terminated C string this MyString object represents.
- const char * c_string() const { return c_string_; }
+ const char* c_string() const { return c_string_; }
size_t Length() const {
return c_string_ == NULL ? 0 : strlen(c_string_);
}
// Sets the 0-terminated C string this MyString object represents.
- void Set(const char * c_string);
+ void Set(const char* c_string);
};
diff --git a/gtest/samples/sample2_unittest.cc b/gtest/samples/sample2_unittest.cc
index e1d7910..32232d9 100644
--- a/gtest/samples/sample2_unittest.cc
+++ b/gtest/samples/sample2_unittest.cc
@@ -71,7 +71,7 @@ TEST(MyString, DefaultConstructor) {
// </TechnicalDetails>
EXPECT_STREQ(NULL, s.c_string());
- EXPECT_EQ(0, s.Length());
+ EXPECT_EQ(0u, s.Length());
}
const char kHelloString[] = "Hello, world!";
diff --git a/gtest/samples/sample3-inl.h b/gtest/samples/sample3-inl.h
index 630e950..46369a0 100644
--- a/gtest/samples/sample3-inl.h
+++ b/gtest/samples/sample3-inl.h
@@ -51,23 +51,23 @@ class QueueNode {
public:
// Gets the element in this node.
- const E & element() const { return element_; }
+ const E& element() const { return element_; }
// Gets the next node in the queue.
- QueueNode * next() { return next_; }
- const QueueNode * next() const { return next_; }
+ QueueNode* next() { return next_; }
+ const QueueNode* next() const { return next_; }
private:
// Creates a node with a given element value. The next pointer is
// set to NULL.
- QueueNode(const E & element) : element_(element), next_(NULL) {}
+ QueueNode(const E& an_element) : element_(an_element), next_(NULL) {}
// We disable the default assignment operator and copy c'tor.
- const QueueNode & operator = (const QueueNode &);
- QueueNode(const QueueNode &);
+ const QueueNode& operator = (const QueueNode&);
+ QueueNode(const QueueNode&);
E element_;
- QueueNode * next_;
+ QueueNode* next_;
};
template <typename E> // E is the element type.
@@ -84,8 +84,8 @@ public:
void Clear() {
if (size_ > 0) {
// 1. Deletes every node.
- QueueNode<E> * node = head_;
- QueueNode<E> * next = node->next();
+ QueueNode<E>* node = head_;
+ QueueNode<E>* next = node->next();
for (; ;) {
delete node;
node = next;
@@ -103,19 +103,19 @@ public:
size_t Size() const { return size_; }
// Gets the first element of the queue, or NULL if the queue is empty.
- QueueNode<E> * Head() { return head_; }
- const QueueNode<E> * Head() const { return head_; }
+ QueueNode<E>* Head() { return head_; }
+ const QueueNode<E>* Head() const { return head_; }
// Gets the last element of the queue, or NULL if the queue is empty.
- QueueNode<E> * Last() { return last_; }
- const QueueNode<E> * Last() const { return last_; }
+ QueueNode<E>* Last() { return last_; }
+ const QueueNode<E>* Last() const { return last_; }
// Adds an element to the end of the queue. A copy of the element is
// created using the copy constructor, and then stored in the queue.
// Changes made to the element in the queue doesn't affect the source
// object, and vice versa.
- void Enqueue(const E & element) {
- QueueNode<E> * new_node = new QueueNode<E>(element);
+ void Enqueue(const E& element) {
+ QueueNode<E>* new_node = new QueueNode<E>(element);
if (size_ == 0) {
head_ = last_ = new_node;
@@ -129,19 +129,19 @@ public:
// Removes the head of the queue and returns it. Returns NULL if
// the queue is empty.
- E * Dequeue() {
+ E* Dequeue() {
if (size_ == 0) {
return NULL;
}
- const QueueNode<E> * const old_head = head_;
+ const QueueNode<E>* const old_head = head_;
head_ = head_->next_;
size_--;
if (size_ == 0) {
last_ = NULL;
}
- E * element = new E(old_head->element());
+ E* element = new E(old_head->element());
delete old_head;
return element;
@@ -151,9 +151,9 @@ public:
// returns the result in a new queue. The original queue is not
// affected.
template <typename F>
- Queue * Map(F function) const {
- Queue * new_queue = new Queue();
- for (const QueueNode<E> * node = head_; node != NULL; node = node->next_) {
+ Queue* Map(F function) const {
+ Queue* new_queue = new Queue();
+ for (const QueueNode<E>* node = head_; node != NULL; node = node->next_) {
new_queue->Enqueue(function(node->element()));
}
@@ -161,13 +161,13 @@ public:
}
private:
- QueueNode<E> * head_; // The first node of the queue.
- QueueNode<E> * last_; // The last node of the queue.
+ QueueNode<E>* head_; // The first node of the queue.
+ QueueNode<E>* last_; // The last node of the queue.
size_t size_; // The number of elements in the queue.
// We disallow copying a queue.
- Queue(const Queue &);
- const Queue & operator = (const Queue &);
+ Queue(const Queue&);
+ const Queue& operator = (const Queue&);
};
#endif // GTEST_SAMPLES_SAMPLE3_INL_H_
diff --git a/gtest/samples/sample3_unittest.cc b/gtest/samples/sample3_unittest.cc
index a3d26da..34c1ca8 100644
--- a/gtest/samples/sample3_unittest.cc
+++ b/gtest/samples/sample3_unittest.cc
@@ -122,7 +122,7 @@ class QueueTest : public testing::Test {
// Tests the default c'tor.
TEST_F(QueueTest, DefaultConstructor) {
// You can access data in the test fixture here.
- EXPECT_EQ(0, q0_.Size());
+ EXPECT_EQ(0u, q0_.Size());
}
// Tests Dequeue().
@@ -133,13 +133,13 @@ TEST_F(QueueTest, Dequeue) {
n = q1_.Dequeue();
ASSERT_TRUE(n != NULL);
EXPECT_EQ(1, *n);
- EXPECT_EQ(0, q1_.Size());
+ EXPECT_EQ(0u, q1_.Size());
delete n;
n = q2_.Dequeue();
ASSERT_TRUE(n != NULL);
EXPECT_EQ(2, *n);
- EXPECT_EQ(1, q2_.Size());
+ EXPECT_EQ(1u, q2_.Size());
delete n;
}
diff --git a/gtest/samples/sample5_unittest.cc b/gtest/samples/sample5_unittest.cc
index be5df90..49dae7c 100644
--- a/gtest/samples/sample5_unittest.cc
+++ b/gtest/samples/sample5_unittest.cc
@@ -171,24 +171,24 @@ class QueueTest : public QuickTest {
// Tests the default constructor.
TEST_F(QueueTest, DefaultConstructor) {
- EXPECT_EQ(0, q0_.Size());
+ EXPECT_EQ(0u, q0_.Size());
}
// Tests Dequeue().
TEST_F(QueueTest, Dequeue) {
- int * n = q0_.Dequeue();
+ int* n = q0_.Dequeue();
EXPECT_TRUE(n == NULL);
n = q1_.Dequeue();
EXPECT_TRUE(n != NULL);
EXPECT_EQ(1, *n);
- EXPECT_EQ(0, q1_.Size());
+ EXPECT_EQ(0u, q1_.Size());
delete n;
n = q2_.Dequeue();
EXPECT_TRUE(n != NULL);
EXPECT_EQ(2, *n);
- EXPECT_EQ(1, q2_.Size());
+ EXPECT_EQ(1u, q2_.Size());
delete n;
}
diff --git a/gtest/samples/sample7_unittest.cc b/gtest/samples/sample7_unittest.cc
index b5d507a..f455282 100644
--- a/gtest/samples/sample7_unittest.cc
+++ b/gtest/samples/sample7_unittest.cc
@@ -121,12 +121,12 @@ INSTANTIATE_TEST_CASE_P(
#else
-// Google Test doesn't support value-parameterized tests on some platforms
-// and compilers, such as MSVC 7.1. If we use conditional compilation to
-// compile out all code referring to the gtest_main library, MSVC linker
-// will not link that library at all and consequently complain about
-// missing entry point defined in that library (fatal error LNK1561:
-// entry point must be defined). This dummy test keeps gtest_main linked in.
+// Google Test may not support value-parameterized tests with some
+// compilers. If we use conditional compilation to compile out all
+// code referring to the gtest_main library, MSVC linker will not link
+// that library at all and consequently complain about missing entry
+// point defined in that library (fatal error LNK1561: entry point
+// must be defined). This dummy test keeps gtest_main linked in.
TEST(DummyTest, ValueParameterizedTestsAreNotSupportedOnThisPlatform) {}
#endif // GTEST_HAS_PARAM_TEST
diff --git a/gtest/samples/sample8_unittest.cc b/gtest/samples/sample8_unittest.cc
index d76136a..ccf61d9 100644
--- a/gtest/samples/sample8_unittest.cc
+++ b/gtest/samples/sample8_unittest.cc
@@ -162,12 +162,12 @@ INSTANTIATE_TEST_CASE_P(MeaningfulTestParameters,
#else
-// Google Test doesn't support Combine() on some platforms and compilers,
-// such as MSVC 7.1. If we use conditional compilation to compile out
-// all code referring to the gtest_main library, MSVC linker will not
-// link that library at all and consequently complain about missing entry
-// point defined in that library (fatal error LNK1561: entry point must
-// be defined). This dummy test keeps gtest_main linked in.
+// Google Test may not support Combine() with some compilers. If we
+// use conditional compilation to compile out all code referring to
+// the gtest_main library, MSVC linker will not link that library at
+// all and consequently complain about missing entry point defined in
+// that library (fatal error LNK1561: entry point must be
+// defined). This dummy test keeps gtest_main linked in.
TEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {}
#endif // GTEST_HAS_COMBINE
diff --git a/gtest/samples/sample9_unittest.cc b/gtest/samples/sample9_unittest.cc
index 8944c47..d828ef4 100644
--- a/gtest/samples/sample9_unittest.cc
+++ b/gtest/samples/sample9_unittest.cc
@@ -52,7 +52,7 @@ namespace {
class TersePrinter : public EmptyTestEventListener {
private:
// Called before any test activity starts.
- virtual void OnTestProgramStart(const UnitTest& unit_test) {}
+ virtual void OnTestProgramStart(const UnitTest& /* unit_test */) {}
// Called after all test activities have ended.
virtual void OnTestProgramEnd(const UnitTest& unit_test) {