📝 One of the difficult unit tester for ft_containers project

Overview

ft_containers-unit-test

screenshot

About

ft containers unit test is a complete testing for project of school 21/ecole 42 and allowing you test your containers: Vector, Stack, Map, Set and Utilities in ft namespace.
This test checks 90% of subject and checklist requires: using std allocator, iterator traits, benchmark, leaks, segfaults, timeouts etc. But keep in mind that test doesn't check something you don't need to implement and was written by students, so im waiting for your bugs or suggestions for improving

Getting started

⚙️ Installation

run this command inside your ft_containers folder:

git clone https://github.com/divinepet/ft_containers-unit-test

then

cd ft_containers-unit-test

now you need to configure file config.hpp and write correct names of all your files and classes, and the last step is

./start.sh

⚠️ config.hpp

if you haven't some class implementation yet, for example Map, you need to comment appropriate line:

...
// #define MAP     "../../../Map.hpp"
...

and etc. for other. The same with flags - comment this line to turn off them

// #define FLAGS

📄 start.sh

you can run tests with a specific container, use flags for this

./start.sh -v # for vector
./start.sh -u # for utilities
./start.sh -st # for stack
./start.sh -m # for map
./start.sh -s # for set
./start.sh -h # help with commands

Results

NOT COMPILED means that method compiles with errors, also probably some template name in config.hpp is incorrect
TIMEOUT means the method exceeded the maximal execution time, probably due to an infinite loop

Press Star ⭐ button in the right corener if this test was useful to you, so that more people can see it

Comments
  • Cannot compile on linux

    Cannot compile on linux

    Hello! I'm trying to run your tester on linux and i always get this error that i can't fix even on the 42's Xubuntu VM

    image

    Is your tester supposed to be run only on mac? or is there some workaround to make it compile on linux?

    opened by frdescam 2
  • Use `ft::swap` instead of `std::swap` for re-implementation tests

    Use `ft::swap` instead of `std::swap` for re-implementation tests

    As explained in this open issue, some tests are not using ft::swap, making the tests fail. I might be wrong, but I think there's no way of using std::swap with our own re-implementations.

    opened by nicolasgasco 0
  • Bug: huge difference in time of `erase` vector method

    Bug: huge difference in time of `erase` vector method

    I am getting a huge different in time between my implementation of vector::erase and the std one. Screenshot 2022-12-10 at 20 50 42

    My implementation is already pretty lean:

    iterator erase(iterator position)
    {
        this->_alloc.destroy(&(*position));
        for (iterator it = position; it < (this->end() - 1); ++it)
            this->_alloc.construct(&(*(it)), *(it + 1));
        this->_alloc.destroy(this->_data + this->_size - 1);
        this->_size--;
        return position;
    }
    

    What seems suspicious to me is that I'm pratically getting the same times no matter how much I tweak my code. Also, I'm not getting such a huge difference in my own tests: Screenshot 2022-12-10 at 23 05 13

    What seems especially suspicious is std time in your tester.

    opened by nicolasgasco 0
  • Improvement: add diff generation

    Improvement: add diff generation

    Hi!

    First of all, a big thank you for this. It is by far the most complete tester regarding the types of checks done.

    I find debugging a bit difficult, though. I would find very useful to have some sort of diff generation.

    Thank you again anyway!

    opened by nicolasgasco 0
  • Problem at compilation of vector test.

    Problem at compilation of vector test.

    The compiler write this when i want to execute the test. And this message is the same for almost every vector test. The error seem so basic i cannot understand it. Here you can find my code, i cannot find where the issue come from.

    https://github.com/kafim909/ft_containers/blob/master/vector.hpp

    COMPILER :

    In file included from ../vector_tests/begin().cpp:2: ../vector_tests/__service.ipp:18:15: error: no matching constructor for initialization of 'ft::vector' res2 = func2(my_vector); ^~~~~~~~~ ../vector_tests/begin().cpp:28:10: note: in instantiation of function template specialization 'run_vector_unit_test' requested here exit(run_vector_unit_test("begin()", begin_test, begin_test)); ^ 1 error generated. generated. tor_std_test, constructor_std_test)); ^ 1 error generated.

    Thanks for helping me with this!

    opened by kafim909 1
  • bug: swap test in vector does not test ft::swap

    bug: swap test in vector does not test ft::swap

    template std::vector swap_test( _vector vector ) { std::vector v; vector.assign( 1100 * _ratio, 11 ); _vector tmp( 500 * _ratio, 5 ), tmp2( 1000 * _ratio, 10 ), tmp3( 1500 * _ratio, 15 ), tmp4( 3000 * _ratio, 30 ); g_start2 = timer(); v.push_back( vector[2] ); v.push_back( vector.size() ); v.push_back( vector.capacity() ); long *adr1 = reinterpret_cast<long *>( &vector ); long *adr2 = reinterpret_cast<long *>( &tmp ); vector.swap( tmp ); if ( reinterpret_cast<long *>( &vector ) == adr1 && reinterpret_cast<long *>( &tmp ) == adr2 ) v.push_back( 1 ); v.push_back( vector[2] ); v.push_back( vector.size() ); v.push_back( vector.capacity() ); vector.swap( tmp3 ); v.push_back( vector[2] ); v.push_back( vector.size() ); v.push_back( vector.capacity() ); std::swap( vector, tmp2 ); --> ft::swap(...) v.push_back( vector[2] ); v.push_back( vector.size() ); v.push_back( vector.capacity() ); std::swap( vector, tmp4 ); --> ft::swap(...) g_end2 = timer(); v.push_back( vector[2] ); v.push_back( vector.size() ); v.push_back( vector.capacity() ); return v; }

    opened by lscitl 1
  • bug: iterator_traits test is wrong

    bug: iterator_traits test is wrong

    I think sources/utilities_tests/iterator_traits.cpp file is doing wrong test!

    It is doing test for std::vector's iterator types and ft::vector's iterator types is same.

    but we need to test for ft::iterator_traits is doing well like this

    bool iterator_traits_test() {
      std::vector<string> res;
      std::vector<string> res2;
      g_start1 = g_end1 = timer();
    
      res.push_back(typeid(std::iterator_traits<std::map<int, int>::iterator>::iterator_category).name());
      res.push_back(typeid(std::iterator_traits<std::map<int, int>::iterator>::value_type).name());
      res.push_back(typeid(std::iterator_traits<std::map<int, int>::iterator>::difference_type).name());
      res.push_back(typeid(std::iterator_traits<std::map<int, int>::iterator>::pointer).name());
      res.push_back(typeid(std::iterator_traits<std::map<int, int>::iterator>::reference).name());
      res.push_back(typeid(std::iterator_traits<std::map<int, int>::reverse_iterator>::iterator_category).name());
      res.push_back(typeid(std::iterator_traits<std::map<int, int>::reverse_iterator>::value_type).name());
      res.push_back(typeid(std::iterator_traits<std::map<int, int>::reverse_iterator>::difference_type).name());
      res.push_back(typeid(std::iterator_traits<std::map<int, int>::reverse_iterator>::pointer).name());
      res.push_back(typeid(std::iterator_traits<std::map<int, int>::reverse_iterator>::reference).name());
    
      res2.push_back(typeid(ft::iterator_traits<std::map<int, int>::iterator>::iterator_category).name());
      res2.push_back(typeid(ft::iterator_traits<std::map<int, int>::iterator>::value_type).name());
      res2.push_back(typeid(ft::iterator_traits<std::map<int, int>::iterator>::difference_type).name());
      res2.push_back(typeid(ft::iterator_traits<std::map<int, int>::iterator>::pointer).name());
      res2.push_back(typeid(ft::iterator_traits<std::map<int, int>::iterator>::reference).name());
      res2.push_back(typeid(ft::iterator_traits<std::map<int, int>::reverse_iterator>::iterator_category).name());
      res2.push_back(typeid(ft::iterator_traits<std::map<int, int>::reverse_iterator>::value_type).name());
      res2.push_back(typeid(ft::iterator_traits<std::map<int, int>::reverse_iterator>::difference_type).name());
      res2.push_back(typeid(ft::iterator_traits<std::map<int, int>::reverse_iterator>::pointer).name());
      res2.push_back(typeid(ft::iterator_traits<std::map<int, int>::reverse_iterator>::reference).name());
    
      return res == res2;
    }
    
    opened by 42mypark 0
Owner
Erik
school 21 student, java developer trainee
Erik
C++ Unit Testing Easier: A Header-only C++ unit testing framework

CUTE C++ Unit Testing Easier: A Header-only C++ unit testing framework usually available as part of the Cevelop C++ IDE (http://cevelop.com) Dependenc

Peter Sommerlad 36 Dec 26, 2022
A modern, C++-native, header-only, test framework for unit-tests, TDD and BDD - using C++11, C++14, C++17 and later (or C++03 on the Catch1.x branch)

Catch2 v3 is being developed! You are on the devel branch, where the next major version, v3, of Catch2 is being developed. As it is a significant rewo

Catch Org 16k Jan 9, 2023
A dynamic mock tool for C/C++ unit test on Linux&MacOS X86_64

lmock 接口 替换一个函数,修改机器指令,用新函数替换旧函数,支持全局函数(包括第三方和系统函数)、成员函数(包括静态和虚函数)

null 55 Dec 21, 2022
A modern, C++11-native, single-file header-only, tiny framework for unit-tests, TDD and BDD (includes C++98 variant)

lest – lest errors escape testing This tiny C++11 test framework is based on ideas and examples by Kevlin Henney [1,2] and on ideas found in the CATCH

Martin Moene 355 Dec 28, 2022
UT: C++20 μ(micro)/Unit Testing Framework

"If you liked it then you "should have put a"_test on it", Beyonce rule UT / μt | Motivation | Quick Start | Overview | Tutorial | Examples | User Gui

boost::ext 956 Jan 3, 2023
A micro unit-testing library for C/C++

µ-test A micro unit testing framework for C/C++ to get you up and running with unit-testing ASAP (even without libc). Usage Simply include the C and h

Trevor McKay 1 Dec 8, 2021
A complete unit testing framework in a header

liblittletest A complete unit testing framework in a header liblittletest is an easy to use all-in-an-header testing framework; all you have to do in

Sebastiano Merlino 13 Nov 11, 2021
Modern c++17 unit testing framework on Microsoft Windows, Apple macOS, Linux, iOS and android.

tunit Modern c++17 unit testing framework on Windows, macOS, Linux, iOS and android. Continuous Integration build status Operating system Status Windo

Gammasoft 8 Apr 5, 2022
Various Framework to do Unit Test in C++

Unit Test in C++ There are many frameworks to performs unit test in C++, we will present the most popular ones and show how to use them. The testing f

Yassine 2 Nov 18, 2021
Upp11 - C++11 lightweight single header unit test framework

upp11 Lightweight C++11 single header unit test framework To use framework: Copy upp11.h in you project dir. Create unit test source files or modify e

Andrey Valyaev 8 Apr 4, 2019
Kernel-mode C++ unit testing framework in BDD-style

There is a lack of unit testing frameworks that work in OS kernel. This library closes that gap and is targeted for windows driver developers.

Sergey Podobry 43 Dec 28, 2022
C unit tests with a small header-only library.

C unit tests Minimalistic unit tests in C. Uses the __attribute__((constructor)) which, as far as I know, is supported by GCC and clang. So this proba

Ruben van Nieuwpoort 62 Dec 5, 2022
A simple, cross-platform, and continuously integrated C++14 project template

Project Name A simple, cross-platform, and continuously integrated C++14 project template. Making cross platform C++ projects is widely known to be a

Arnav Borborah 63 Dec 5, 2022
Project basicly find the test that fails some code.

Stress Test project Overview many and many times in competitve programming when you have a solution got WA(wrong answer) and you do not know why and c

Omar Abdel-Ghani 3 Feb 15, 2022
✔️The smallest header-only GUI library(4 KLOC) for all platforms

Welcome to GUI-lite The smallest header-only GUI library (4 KLOC) for all platforms. 中文 Lightweight ✂️ Small: 4,000+ lines of C++ code, zero dependenc

null 6.6k Jan 8, 2023
Starting with OpenCV and Qt on MacOS is a bit of difficult if you haven't installed and used libraries in XCode.

OpenCV and Qt on MacOS Introduction Starting with OpenCV and Qt on MacOS is a bit of difficult if you haven't installed and used libraries in XCode. T

Martin Kersting 3 Oct 20, 2022
A tester for the ft_printf 42 project.

ft_printf tester A tester for 42's ft_printf project. Updated for the new specification (2021 2nd semester) It runs a series of tests against ft_print

Paulo Santana 80 Nov 27, 2022
A Tester for the Libft 42 project based off Tripouille

libfttester A Tester for the Libft 42 project This Tester was made by NotJustJoe, using Tripouille Leaks checker and kind of inspired off his work (ht

trofidal 7 May 20, 2022
The C Unit Testing Library on GitHub is a library designed for easy unit testing in C

The C Unit Testing Library on GitHub is a library designed for easy unit testing in C. It was written by Brennan Hurst for the purpose of providing a J-Unit-like testing framework within C for personal projects.

null 1 Oct 11, 2021