move to cmake
This commit is contained in:
		
							
								
								
									
										20
									
								
								test/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								test/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
enable_testing()
 | 
			
		||||
find_package(GTest REQUIRED)
 | 
			
		||||
 | 
			
		||||
add_executable(dtl_test 
 | 
			
		||||
  test/Intdifftest.cpp
 | 
			
		||||
  test/Objdifftest.cpp
 | 
			
		||||
  test/Patchtest.cpp
 | 
			
		||||
  test/Strdiff3test.cpp
 | 
			
		||||
  test/Strdifftest.cpp
 | 
			
		||||
  test/dtl_test.cpp
 | 
			
		||||
  test/dtl_test_common.cpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
target_include_directories(dtl_test BEFORE PRIVATE
 | 
			
		||||
  ${CMAKE_CURRENT_SOURCE_DIR}/test
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
target_link_libraries(dtl_test GTest::gtest GTest::gtest_main)
 | 
			
		||||
 | 
			
		||||
add_test(AllTests dtl_test)
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
#include "comparators.hpp"
 | 
			
		||||
#include "dtl_test_common.hpp"
 | 
			
		||||
 | 
			
		||||
#include "comparators.hpp"
 | 
			
		||||
 | 
			
		||||
class Objdifftest : public ::testing::Test {
 | 
			
		||||
protected:
 | 
			
		||||
  dtl_test_typedefs(string, vector<elem>) typedef struct case_t {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,40 +0,0 @@
 | 
			
		||||
# -*- coding: utf-8 -*-
 | 
			
		||||
# SConstrunct for dtl test
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def path_chomp(path):
 | 
			
		||||
    if path[-1] == '/':
 | 
			
		||||
        return path[:-1]
 | 
			
		||||
    return path
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
env = Environment(
 | 
			
		||||
    CPPFLAGS=['-Wall', '-O2'],
 | 
			
		||||
    CPPPATH=['..'],
 | 
			
		||||
    CXXFLAGS="-std=c++11",
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
conf = Configure(env)
 | 
			
		||||
 | 
			
		||||
if not conf.CheckCXX():
 | 
			
		||||
    print("c++ compiler is not installed!")
 | 
			
		||||
    Exit(1)
 | 
			
		||||
 | 
			
		||||
libs = ['stdc++', 'pthread', 'gtest']
 | 
			
		||||
for lib in libs:
 | 
			
		||||
    if not conf.CheckLib(lib):
 | 
			
		||||
        print("library " + lib + " not installed!")
 | 
			
		||||
        Exit(1)
 | 
			
		||||
 | 
			
		||||
conf.Finish()
 | 
			
		||||
 | 
			
		||||
test = env.Program(
 | 
			
		||||
    'dtl_test',
 | 
			
		||||
    [Glob('*.cpp')],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
test_alias = env.Alias('check', test, test[0].abspath)
 | 
			
		||||
 | 
			
		||||
env.AlwaysBuild(test_alias)
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
#include "comparators.hpp"
 | 
			
		||||
#include "dtl_test_common.hpp"
 | 
			
		||||
 | 
			
		||||
#include "comparators.hpp"
 | 
			
		||||
 | 
			
		||||
class Strdiff3test : public ::testing::Test {
 | 
			
		||||
protected:
 | 
			
		||||
  dtl_test_typedefs(char, string) typedef struct case_t {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
#include "comparators.hpp"
 | 
			
		||||
#include "dtl_test_common.hpp"
 | 
			
		||||
 | 
			
		||||
#include "comparators.hpp"
 | 
			
		||||
 | 
			
		||||
class Strdifftest : public ::testing::Test {
 | 
			
		||||
protected:
 | 
			
		||||
  dtl_test_typedefs(char, string) typedef struct case_t {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +1,18 @@
 | 
			
		||||
#ifndef DTL_COMPARATORS
 | 
			
		||||
#define DTL_COMPARATORS
 | 
			
		||||
 | 
			
		||||
#include "functors.hpp"
 | 
			
		||||
 | 
			
		||||
class CaseInsensitive : public dtl::Compare<char> {
 | 
			
		||||
public:
 | 
			
		||||
  virtual bool impl(const char &a, const char &b) const {
 | 
			
		||||
    return tolower(a) == tolower(b);
 | 
			
		||||
    return std::tolower(a) == std::tolower(b);
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class StringCaseInsensitive : public dtl::Compare<string> {
 | 
			
		||||
class StringCaseInsensitive : public dtl::Compare<std::string> {
 | 
			
		||||
public:
 | 
			
		||||
  virtual bool impl(const string &a, const string &b) const {
 | 
			
		||||
  virtual bool impl(const std::string &a, const std::string &b) const {
 | 
			
		||||
    if (a.length() == b.length()) {
 | 
			
		||||
      bool equal = (strncasecmp(a.c_str(), b.c_str(), a.length()) == 0);
 | 
			
		||||
      return equal;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,4 @@
 | 
			
		||||
/**
 | 
			
		||||
 * It is necessary to use googletest to run tests.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <gtest/gtest.h>
 | 
			
		||||
#include "dtl_test_common.hpp"
 | 
			
		||||
 | 
			
		||||
int main(int argc, char *argv[]) {
 | 
			
		||||
  ::testing::InitGoogleTest(&argc, argv);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,3 @@
 | 
			
		||||
 | 
			
		||||
#include "dtl_test_common.hpp"
 | 
			
		||||
 | 
			
		||||
string create_path(const string &test_name, string diff_name, enum type_diff t,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,9 @@
 | 
			
		||||
 | 
			
		||||
#ifndef DTL_TEST_COMMON
 | 
			
		||||
#define DTL_TEST_COMMON
 | 
			
		||||
 | 
			
		||||
#include <cstdio>
 | 
			
		||||
#include <dtl/dtl.hpp>
 | 
			
		||||
#include <fstream>
 | 
			
		||||
#include <gtest/gtest.h>
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <utility>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
#include "dtl.hpp"
 | 
			
		||||
 | 
			
		||||
using std::cerr;
 | 
			
		||||
using std::endl;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user