Apply formatting/style tweaks to comply with compile time diagnostics for g++ and clang++ (#686)

* Add compilation flags: -Wshadow -Weffc++ -pedantic -pedantic-errors
* Delete implicit copy & move constructors & assignment operators
  in classes with pointer data members.
* An exception to the above: Add default copy & move constructors &
  assignment operators for the Binary class.
* Convert boolean RegEx operators to binary operators.
* Initialize all members in all classes in ctors.
* Let default ctor delegate to the converting ctor in
  Binary and RegEx
* Don't change any tests except regex_test (as a result of the change
  to binary operators).

Note: https://bugzilla.redhat.com/show_bug.cgi?id=1544675 makes
-Weffc++ report a false positive in "include/yaml-cpp/node/impl.h".
This commit is contained in:
Ted Lyngmo
2019-03-13 23:18:34 +01:00
committed by Jesse Beder
parent eca9cfd648
commit 0d5c57150c
40 changed files with 285 additions and 241 deletions

View File

@@ -1,6 +1,6 @@
#include "gtest/gtest.h"
#include "regex_yaml.h"
#include "stream.h"
#include "gtest/gtest.h"
using YAML::RegEx;
using YAML::Stream;
@@ -106,8 +106,8 @@ TEST(RegExTest, OperatorOr) {
for (int j = i + 1; j < 128; ++j) {
auto iStr = std::string(1, char(i));
auto jStr = std::string(1, char(j));
RegEx ex1 = RegEx(iStr) || RegEx(jStr);
RegEx ex2 = RegEx(jStr) || RegEx(iStr);
RegEx ex1 = RegEx(iStr) | RegEx(jStr);
RegEx ex2 = RegEx(jStr) | RegEx(iStr);
for (int k = MIN_CHAR; k < 128; ++k) {
auto str = std::string(1, char(k));
@@ -128,8 +128,8 @@ TEST(RegExTest, OperatorOr) {
}
TEST(RegExTest, OperatorOrShortCircuits) {
RegEx ex1 = RegEx(std::string("aaaa")) || RegEx(std::string("aa"));
RegEx ex2 = RegEx(std::string("aa")) || RegEx(std::string("aaaa"));
RegEx ex1 = RegEx(std::string("aaaa")) | RegEx(std::string("aa"));
RegEx ex2 = RegEx(std::string("aa")) | RegEx(std::string("aaaa"));
EXPECT_TRUE(ex1.Matches(std::string("aaaaa")));
EXPECT_EQ(4, ex1.Match(std::string("aaaaa")));
@@ -139,13 +139,13 @@ TEST(RegExTest, OperatorOrShortCircuits) {
}
TEST(RegExTest, OperatorAnd) {
RegEx emptySet = RegEx('a') && RegEx();
RegEx emptySet = RegEx('a') & RegEx();
EXPECT_FALSE(emptySet.Matches(std::string("a")));
}
TEST(RegExTest, OperatorAndShortCircuits) {
RegEx ex1 = RegEx(std::string("aaaa")) && RegEx(std::string("aa"));
RegEx ex2 = RegEx(std::string("aa")) && RegEx(std::string("aaaa"));
RegEx ex1 = RegEx(std::string("aaaa")) & RegEx(std::string("aa"));
RegEx ex2 = RegEx(std::string("aa")) & RegEx(std::string("aaaa"));
EXPECT_TRUE(ex1.Matches(std::string("aaaaa")));
EXPECT_EQ(4, ex1.Match(std::string("aaaaa")));
@@ -174,4 +174,4 @@ TEST(RegExTest, StringOr) {
EXPECT_EQ(1, ex.Match(str));
}
}
} // namespace