Questions tagged [unit-testing]
Use this tag for code whose main focus is high-performance testing of the actual functional code.
1,044 questions
4
votes
1
answer
176
views
Checking for string isomorphism in Java
Intro
Two \$n\$-strings \$s = \langle s_1 \ldots s_n \rangle \$ and \$z = \langle z_z \ldots z_n \rangle\$ are considered isomorphic if and only if there exists a bijection \$f\$ such that for all \$...
4
votes
1
answer
78
views
Catch2 Sections as Macros
I like from the C++ unit test framework Catch2 its sections -- much more than the xUnit test fixtures. Therefore I wrote me some macros which mimic the Catch2 sections.
This is the first macro heavy ...
5
votes
1
answer
386
views
Trying Out DDD : How to enforce data integrity and immutability
I've been transitioning from type-safe programming languages like Dart and Java to Python, and I'm trying to enforce Domain-Driven Design (DDD) principles in a language that naturally leans towards ...
2
votes
2
answers
172
views
C++20 Performance Test Code Generator
My previous question about a generic dictionary class for C++ raised some valid concerns. I have made some modifications based on the previous review, but it needs extensive testing and further ...
3
votes
1
answer
154
views
Testing framework with a single assertion macro
I usually use the Catch2 testing framework in my C++ projects. Unlike other frameworks, it has only one core assertion macro for all comparisons. Instead of writing ...
1
vote
1
answer
126
views
Project for reading and printing IPs
It's a small project which consists of Ip class and functions for reading and printing IPs, unit tests for this code, and a driver app. The driver app is just ...
2
votes
0
answers
62
views
Testing PHP CodeIgniter 3 controller with PHPUnit
I want to unit test my PHP website, which uses the outdated framework CodeIgniter 3. CodeIgniter 3 uses the MVC pattern, and each page on the website corresponds to a public method in a controller.
I ...
1
vote
1
answer
118
views
Generic Min() for Integer Types (including Boolean)
This is a follow-up to Generic Max() for Integer Types (including Boolean) and An Attempt at Creating Generic Min()/Max() for Fundamental Types.
What's new:
MIN(), ...
4
votes
3
answers
240
views
Stub-Based Unit Testing 5 Read Routines
Requirements:
Following are the functions I need to test, along with the cases where they can fail:
...
1
vote
2
answers
113
views
simple Text Table utility
A small utility to print data in an ascii table
TextTable
...
3
votes
1
answer
156
views
A simple unit test library for C - version II
I have improved my code here and it looks like this:
Code
assertlib.h:
...
1
vote
1
answer
96
views
Event manager based on decorators
This module is a simple event manager that works with decorators. I would like feedback on:
Bugs
Any ideas to get rid of the classevent decorator, which ...
1
vote
1
answer
84
views
Testing code for An+B microsyntax parsing library
I have a small package that provides some API for playing around with the <An+B> CSS microsyntax. It is 100% type hinted and tested, but doesn't actually have any real/useful features and this ...
2
votes
1
answer
278
views
Test suite for population-count function, using random input
For the purpose of this discussion, I have the following function:
...
1
vote
2
answers
1k
views
Multi-Client Socket Communication with Thread Pool in C++
I've been working on implementing a multi-client socket communication system with a thread pool in C++. The system comprises three main components: logger.h, socket.h, and thread.h, which handle ...
1
vote
1
answer
172
views
Change unit-test structure to avoid try/except/finally clause
I have 10 or 20 tests with the same structure which I would like to improve. The test itself is nested within a try/except/finally clause to make sure that some of ...
4
votes
3
answers
418
views
Money class in python
I have recently created the Money class with a helper class Currency. What do you think about the following code? I created unit ...
3
votes
1
answer
123
views
A singly linked list implementation
Here's yet another implementation of a singly linked list. You may base your review on the following questions:
Review goals:
Is the API well thought of?
Does this design include undefined behavior, ...
0
votes
1
answer
71
views
Protein Translation Learning Exercise from exercism.org
I'm learning Rust by solving exercises from different tracks on Exercism.
The below code is an implementation of "Protein Translation" from the Python track. I split ...
1
vote
1
answer
104
views
N dimensional array index utility Improved
This is a continuation from a previous question; I updated the code with the suggestions and added an additional iteration.
Templates are not an option because of the usage: The objects are stored as ...
4
votes
1
answer
2k
views
Transliterate between Cyrillic and Latin scripts
I want to get a code review on the following transliteration code. I wrote it because there were some libraries that I have tried and they were specifically failing with the name "Yuliya" ...
4
votes
2
answers
705
views
Unit testing for a multi-dimensional array class
I have designed a class bunji::Tensor which is a multi-dimensional array. I have designed it to have a similar interface to a multi-dimensional ...
2
votes
2
answers
164
views
Astronomical calculations in C for python bindings
I've started teaching myself c/c++ with the intent of being able to writing python bindings to c code. I have a c library used ...
3
votes
1
answer
157
views
String / Char Vector Concatenation Performance Comparison in Matlab
Considering the suggestion of using modern string arrays instead of char vectors proposed by Cris Luengo, I am trying to make a code snippet for performance comparison of these two cases.
The ...
1
vote
2
answers
134
views
UPDATE on Newspaper Bill Calculator CLI with Python (1 of 3, Core)
Code is posted after explanation.
Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused.
Post 2 of 3, CLI: UPDATE 1 on Newspaper ...