Skip to content
Snippets Groups Projects
Commit 0d92cda6 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

working on writing tests

parent 221dc1cc
No related branches found
No related tags found
No related merge requests found
......@@ -33,3 +33,9 @@ uninstall:
clean:
rm *.o *.a
.PHONY: test
test:
cd test && ./test.sh
version: 0.1
phases:
install:
run-as: root
commands:
- make install
pre_build:
commands:
- g++ --version
- clang++ --version
- alias icpc=g++
build:
commands:
- make
- make test
......@@ -24,10 +24,18 @@
#include <sstream>
#include <type_traits>
#if RLIB_COMPILER_ID == CC_ICC
#define RLIB_IMPL_SSTREAM_DISABLE_TLS
#endif
#if RLIB_COMPILER_IS_MINGW
#define RLIB_IMPL_SSTREAM_DISABLE_TLS
#endif
namespace rlib {
// literals::_format, format_string, string::format
namespace impl {
#ifndef RLIB_MINGW_DISABLE_TLS
#ifndef RLIB_IMPL_SSTREAM_DISABLE_TLS
#if RLIB_CXX_STD < 2017
// Intel C++ compiler has a pending bug for `thread_local inline` variable.
thread_local extern std::stringstream to_string_by_sstream_ss;
......@@ -39,8 +47,9 @@ namespace rlib {
#endif
template <typename VarT>
std::string to_string_by_sstream(VarT &thing) {
#ifdef RLIB_MINGW_DISABLE_TLS // Fix intel C++ bug https://software.intel.com/en-us/forums/intel-c-compiler/topic/784136
// Also fix mingw bug. But much slower!
#if defined(RLIB_IMPL_SSTREAM_DISABLE_TLS)
// Fix intel C++ bug https://software.intel.com/en-us/forums/intel-c-compiler/topic/784136
// Also fix mingw bug. But much slower!
std::stringstream ss;
#else
auto &ss = to_string_by_sstream_ss;
......@@ -52,7 +61,8 @@ namespace rlib {
template<typename... Args>
std::string _format_string_helper(const std::string &fmt, Args... args) {
#ifdef RLIB_MINGW_DISABLE_TLS // Fix intel C++ bug https://software.intel.com/en-us/forums/intel-c-compiler/topic/784136
#if defined(RLIB_IMPL_SSTREAM_DISABLE_TLS)
// Fix intel C++ bug https://software.intel.com/en-us/forums/intel-c-compiler/topic/784136
std::stringstream ss;
#else
auto &ss = _format_string_helper_ss; // cached stringstream is much quicker.
......
......@@ -39,6 +39,12 @@
#include "compiler_detector"
// Define RLIB_COMPILER_ID and RLIB_COMPILER_VER
#if defined(__MINGW32__) || defined(__MINGW64__)
#define RLIB_COMPILER_IS_MINGW 1
#else
#define RLIB_COMPILER_IS_MINGW 0
#endif
// shorthand for __cplusplus macro.
#ifndef RLIB_CXX_STD
# if RLIB_COMPILER_ID == CC_MSVC
......
......@@ -18,24 +18,32 @@
MODULES=string meta trait stdio sio scope_guard
CXXFLAGS=-I.
EXTRA_FLAGS ?=
CXXFLAGS=-I. $(EXTRA_FLAGS)
STD ?= 14
FLAGS11=-std=c++11 rlib/libr.a
FLAGS14=-std=c++14 rlib/libr.a
FLAGS17=-std=c++17
all: cxx14_all cxx17_all
ifeq ($(STD),11)
CXXFLAGS := $(CXXFLAGS) $(FLAGS11)
endif
ifeq ($(STD),14)
CXXFLAGS := $(CXXFLAGS) $(FLAGS14)
endif
ifeq ($(STD),17)
CXXFLAGS := $(CXXFLAGS) $(FLAGS17)
endif
cxx14_all: string_14
POSTFIX=$(STD)_$(CXX)
cxx17_all: string_17
string_14:
$(CXX) $(CXXFLAGS) src/string.cc $(FLAGS14) -o src/string_14.out
src/string_14.out
string_17:
$(CXX) $(CXXFLAGS) src/string.cc $(FLAGS17) -o src/string_17.out
src/string_17.out
all: string
string:
$(CXX) $(CXXFLAGS) src/string.cc $(CXXFLAGS) -o src/string_$(POSTFIX).out
src/string_$(POSTFIX).out
clean:
rm -f src/*.out
#!/bin/bash
for cxx in g++ clang++ icpc
do
for std in 14 17
do
echo "Testing $cxx c++$std..."
make CXX="$cxx" STD="$std"
[[ $? != 0 ]] && echo "Testing $cxx c++$std failed. Exiting..." && exit 1
done
done
echo "All tests passed."
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment