Questions tagged [unit-testing]

Use this tag for code whose main focus is high-performance testing of the actual functional code.

Filter by
Sorted by
Tagged with
1 vote
2 answers
86 views

simple Text Table utility

A small utility to print data in an ascii table TextTable ...
Martin Frank's user avatar
  • 2,828
2 votes
2 answers
73 views

Goal: Writing Effective Unit Tests to Ensure a Datetime Conversion To/From Local-UTC Works

As the title lists, I am trying to write an effective unittest suite to ensure that the function that converts a date to UTC from local or vice-versa is doing as planned. But it seems hard because ...
0004's user avatar
  • 121
3 votes
1 answer
112 views

A simple unit test library for C - version II

I have improved my code here and it looks like this: Code assertlib.h: ...
coderodde's user avatar
  • 28k
7 votes
1 answer
811 views

A simple unit test library for C

(This post is followed up by this one.) I have rolled this simple unit test library for C: com_github_coderodde_my_assert.h: ...
coderodde's user avatar
  • 28k
1 vote
1 answer
60 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 ...
rdesparbes's user avatar
5 votes
1 answer
183 views

Testing binary search module, based on bisect

The bisect module can only find the index to insert an element. I created a simple class based on the bisect module for precise searching and covered all the edge cases that came to mind with tests. ...
Aycon's user avatar
  • 153
1 vote
1 answer
50 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 ...
InSync's user avatar
  • 165
5 votes
3 answers
2k views

Python strong password validator ( with unit test )

Lately, I was studying the concept of unit testing in python, so I have decided to write a imperative strong password validator ( checker ) and also attach a unit test to it. I would like to know if ...
KhodeNima's user avatar
  • 347
2 votes
1 answer
266 views

Test suite for population-count function, using random input

For the purpose of this discussion, I have the following function: ...
joseville's user avatar
  • 456
3 votes
1 answer
84 views

Simulate M random walkers N times and visualize relationship between walker number and grid size

Problem statement: Suppose that n random walkers, starting in the center of an n-by-n grid, move one step at a time, choosing to go left, right, up, or down with equal probability at each step. Write ...
x27ca61a's user avatar
  • 307
1 vote
2 answers
774 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 ...
user avatar
1 vote
1 answer
175 views

HTTP routing with Mongoose

I'm trying to extend the Mongoose RESTful server example with URL routing. This code relies on the Mongoose library available here. This is heavily inspired by the routes class from this question but ...
S Meredith's user avatar
1 vote
1 answer
96 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 ...
Mathieu's user avatar
  • 211
6 votes
3 answers
358 views

Unit testing a Linked List implementation in C++

Recently I wanted to use the gtest library to unit test my program but for some reason, it's incredibly hard to make it work and configure (at least for me it was), ...
I_throw_but_dont_catch's user avatar
4 votes
3 answers
272 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 ...
whiteman808's user avatar
0 votes
0 answers
160 views

Testing Receiver Methods in Golang

I'm trying to test and implement an exercise on receiver method from here. This basically states the following: Cars start with full (100%) batteries Each time you drive a car, it covers the it's ...
Saurabh's user avatar
  • 435
0 votes
0 answers
70 views

Generate INSERTs from function parameters with jinja2

I'm writing unit-tests with pytest for sqlite database and reporting functions and I need to arrange them by inserting minimal ...
t3chb0t's user avatar
  • 44.2k
4 votes
1 answer
255 views

Blocking Queue Class Unit Test

I would like any feedback on making the unit test for a BlockingQueue class more robust or better? improvements to the coding style, use of the ...
KetDog's user avatar
  • 209
3 votes
1 answer
105 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, ...
Harith's user avatar
  • 5,516
-1 votes
0 answers
45 views

Manage Access Control on Swift UI Elements

I have following ViewController class with a tableView. ...
Tharindu Ketipearachchi's user avatar
-1 votes
1 answer
172 views

Test the log in functionality of a web page with incorrect credentials [closed]

I'm new to playwright, so I'm unsure if this is the correct or best way to go about testing. I basically want multiple tests on the same webpage. I've been able to successfully accomplish this using ...
Aeton's user avatar
  • 3
0 votes
1 answer
54 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 ...
Saurabh's user avatar
  • 435
0 votes
1 answer
127 views

Unit testing and alternative to mocking in Haskell

Let's say you have a simple pure function that applies a discount of 30% if the total price of a list of Items is over 30.00 (let's not delve into the fact that I'm ...
Jir's user avatar
  • 201
1 vote
1 answer
71 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 ...
Dávid Tóth's user avatar
4 votes
2 answers
1k views

Clean up directories and files when a unit test fails

While running unit tests (most of them integration tests) with Python I create some directories. They need to be deleted after the test or when the test fails. The execution of the cleanup code need ...
buhtz's user avatar
  • 209
4 votes
1 answer
1k 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" ...
nop's user avatar
  • 739
3 votes
0 answers
172 views

Fluent VBA: One Year Later

A little over a year ago, I asked for feedback on Code Review for a unit testing framework I created in VBA. Development of this project has been off and on for the past year. Sometimes I wouldn't ...
Brian Gonzalez's user avatar
4 votes
2 answers
653 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 ...
finlay morrison's user avatar
4 votes
1 answer
158 views

Python unit tests for storing and loading objects

I wrote some code and thought I may get better with some feedback. I program for almost 5 years, mainly in python. I care most about the unit testing. I am not really sure, how industry standard unit ...
Cjw9000's user avatar
  • 41
2 votes
2 answers
129 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 ...
Jason Leaver's user avatar
3 votes
1 answer
351 views

Unit test for a React click-counting component

Take this basic component using state: ...
user8758206's user avatar
3 votes
1 answer
117 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 ...
JimmyHu's user avatar
  • 4,708
1 vote
0 answers
52 views

Reusable and testable JavaScript code for URL fragment-based tab navigation logic

Foreword As a personal project, I've been creating a SPA blog (available here), which features 4 tabs (Thoughts, Projects, Readings, and CV), each accessible via one of four radio buttons, and several ...
Enlico's user avatar
  • 547
1 vote
0 answers
46 views

UPDATE on Newspaper Bill Calculator CLI with Python (3 of 3, Database)

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 1 of 3, Core: UPDATE 1 on Newspaper ...
eccentricOrange's user avatar
1 vote
2 answers
82 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 ...
eccentricOrange's user avatar
2 votes
0 answers
67 views

Get ffmpeg command to encode video in x265 codec and downscale to `max_height` resolution

I'm translating the python program video-diet as I am learning rust. The program is to recursively compress video files in a directory, but here I'm just preparing ...
user avatar
1 vote
1 answer
85 views

Unit tests for PNGme steganography exercise in Rust

I want to become proficient in Rust and I've followed the PNGme exercise. I've completed it up until Chapter 4 included, where I've written a lot of tests myself for verifying that the command line ...
rdxdkr's user avatar
  • 111
1 vote
0 answers
2k views

Table driven tests in Python using pytest

I'd like to have a standard test template to copy from when solving coding puzzles. Typically, I would need to write multiple test functions to check if my function is working as expected. However, it'...
bluprince13's user avatar
2 votes
1 answer
105 views

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: Newspaper Bill ...
eccentricOrange's user avatar
0 votes
0 answers
534 views

Skeleton unit test for leetcode coding problems

I tried to initiate myself with unit testing the simplest way I can. What do you think of this way to begin with? Is it a clean way to proceed? Are there any major caveats to avoid? NB: Since I want ...
curious's user avatar
  • 293
3 votes
3 answers
273 views

A refactored payment service, handling several payment schemes

I was asked to refactor a class, to make it adhere to SOLID principles, with testability and readability. I thought I had done a decent job, only my feedback was: a) Unnecessary introduction of ...
zola25's user avatar
  • 140
1 vote
1 answer
298 views

Unit tests for a 2D Vector class

I'm writing a vector class for 2D geometry applications, and below is a rough draft for a unit test using Cpputest. I'm familiar with unit tests, but this is the first I've done for a purely ...
Mode77's user avatar
  • 663
2 votes
0 answers
40 views

SpecFlow/gherkin code for creating customers

I am new to BDD/Specflow and was wondering if I could get some feedback on my definitions Here is what I have for a simple customer creation feature/command: ...
Matster2's user avatar
2 votes
1 answer
521 views

Basic Ticket booking code with Unit tests

I am going to run a session for a few other developers who are new to Junit, mocking, etc. I have designed a very simple application with classes and tests to demonstrate how to do unit testing. ...
HariHaravelan's user avatar
0 votes
1 answer
92 views

First time writing tests (Service Layer)

Service class: ...
GodLike's user avatar
  • 51
0 votes
1 answer
133 views

Six different, concise (and hopefuly readable), sorting algorithms using ES6+ idioms, with some basic unit testing

I'm practicing js, unit testing, and algorithms, so implementing some of the common sorting algorithms and doing some basic unit testing on them seemed like a good exercise. I'm also trying to use ...
NPN328's user avatar
  • 761
1 vote
0 answers
71 views

Unit tests coverage of functools extension library

A few days ago I requested a review of my functools extension library. Since I did not have any unit tests for it, I started writing some for the revised version of this library. I'd like some ...
Richard Neumann's user avatar
2 votes
1 answer
191 views

Operator overloading in Image class implementation in C++

This is a follow-up question for Dictionary based non-local mean implementation in C++. There are some issues about operators (operator+ and ...
JimmyHu's user avatar
  • 4,708
0 votes
1 answer
351 views

Sanitize object to only include specific properties

Object Property Sanitization I'm learning to code servers using JavaScript, Node, and Express. While writing controllers that create new entries in the database, the need to sanitize the user input ...
NPN328's user avatar
  • 761
1 vote
1 answer
37 views

Optimize Tests in Rails6 - Minitest - Factory

I finally got this working but I am concerned I am being 'too' specific in my tests, and also that I am repeating myself a significant amount. I could also combine all of the failures into a single ...
StartingRails's user avatar

1
2 3 4 5
21