Skip to main content
13 votes

Python strong password validator ( with unit test )

standard libraries are, umm, standard ...
J_H's user avatar
  • 28.9k
7 votes

A simple unit test library for C

The header doesn't need to include anything except <stddef.h> (to define size_t). These two externs are never used: <...
Toby Speight's user avatar
  • 76.8k
6 votes
Accepted

Unit Tests for an Arena Allocator

Here's something that's not well-defined: static inline bool is_aligned(const void *ptr, size_t byte_count) { return (uintptr_t) ptr % byte_count == 0; } Any ...
Toby Speight's user avatar
  • 76.8k
5 votes

Stub-Based Unit Testing 5 Read Routines

One tiny quibble... Existing code: ...
Fe2O3's user avatar
  • 758
5 votes
Accepted

Testing binary search module, based on bisect

testing approach from unittest import TestCase Good! You may wish to consider using hypothesis, as well. It does an amazing job of thinking up random test cases ...
J_H's user avatar
  • 28.9k
5 votes

Python strong password validator ( with unit test )

Please read this as an addition to two existing answers, I agree with almost all points made there. Whitespace You may like excessive vertical whitespace, it's your choice. But in this case it's a ...
SUTerliakov's user avatar
5 votes

Python strong password validator ( with unit test )

Style Your code is readable, well documented, and mostly follows conventions, nice. My only nitpicks here is that you use snake_case for constants, where these ...
gazoh's user avatar
  • 3,269
5 votes
Accepted

Change unit-test structure to avoid try/except/finally clause

Python uses garbage collection. Objects will be deleted automatically when they are no longer referenced. The del statement doesn't force the object to be destroyed,...
amon's user avatar
  • 12.5k
4 votes
Accepted

Test suite for population-count function, using random input

PEP-8 def countSetBits(num): Ummm, yeah, let me stop you right there. Pythonically we would avoid the java-esque camelCase. And maybe even let the Gentle Reader ...
J_H's user avatar
  • 28.9k
4 votes
Accepted

Generic Max() for Integer Types (including Boolean)

Tests The assert() tests are not useful in release mode as that replaces assert() with empty code. The test within the ...
chux - Reinstate Monica's user avatar
3 votes
Accepted

A simple unit test library for C - version II

In C, void get_exit_status() declares a function that takes an unspecified number of parameters, not a function that takes none. If the function expects no ...
Harith's user avatar
  • 8,377
3 votes
Accepted

Stub-Based Unit Testing 5 Read Routines

The tests seem to be including the source of the code under test, which I don't recommend. It's better if you can link the exact binaries that you built for production, rather than something slightly ...
Toby Speight's user avatar
  • 76.8k
3 votes
Accepted

Generic Min() for Integer Types (including Boolean)

With your header in min.h, the test code in test-min.c, and max.h — which has to be ...
Jonathan Leffler's user avatar
3 votes
Accepted

Unit testing a Linked List implementation in C++

General Observations I am recommending that you take some time to follow the suggestion here and then post a follow up question. What should be handled immediately is the re-partitioning of the ...
pacmaninbw's user avatar
  • 23.9k
3 votes

Unit testing a Linked List implementation in C++

This is going to be a superficial review, I hope someone else will go into details on the C++ code. I don’t see any issues with your makefile, and don’t understand why you would need to include ...
Cris Luengo's user avatar
  • 5,778
2 votes

Skeleton unit test for leetcode coding problems

What do you think of this way to begin with? Meh. Not great, but definitely better than nothing. Is it a clean way to proceed? No. Prefer one of these. Hopefully you'll choose the first one. Put ...
J_H's user avatar
  • 28.9k
2 votes
Accepted

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

fn get_x_coordinate(&self) -> usize { self.x } fn get_y_coordinate(&self) -> usize { self.y } This code breaks C-GETTERS: With a few ...
Marv's user avatar
  • 390
2 votes
Accepted

Multi-Client Socket Communication with Thread Pool in C++

Use of a thread pool What was the point of creating a thread pool with 50 threads if you are going to submit exactly 50 tasks to it? You could have just used ...
G. Sliepen's user avatar
  • 58.3k
2 votes

Unit testing a Linked List implementation in C++

Try to make the interface simpler and more robust Let's look at these two lines in your example usage of your TEST class: ...
G. Sliepen's user avatar
  • 58.3k
2 votes

Testing code for An+B microsyntax parsing library

Kudos for embarking on this adventure! Stochastic testing can certainly reveal surprising things about the target code. VT No idea what your requirements are. But apparently they mention form-feed and ...
J_H's user avatar
  • 28.9k
2 votes

Generic Max() for Integer Types (including Boolean)

Wrong check for C23: #if defined(__STDC_VERSION__) && __STDC_VERSION >= 202311L This check was expected to suffice for GCC 14.1 and Clang 18.1, as they ...
Harith's user avatar
  • 8,377
2 votes

Stub-Based Unit Testing 5 Read Routines

Problem: We have 18 similar source files that only differ in include directives, and the read routine being tested, and the name of the function that is testing the ...
Harith's user avatar
  • 8,377
2 votes

simple Text Table utility

I don't really have a code review. What I have is more of an idea. Possum suggests that you can use a factory. However, I don't think a factory is particularly suitable for this use case. Because the ...
Roman's user avatar
  • 2,843
1 vote

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

Time and date is a deeply gnarly subject, but parsing and comparing can be fairly straighforward. Also note your above code is very slow because it re-initializes the 'tzf' object repeatedly. That ...
jmullee's user avatar
  • 161
1 vote

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

A test suite is an opportunity to clarify what the observable behavior of a Public API is intended to be. The current suite isn't quite there, yet. attribute count Each ...
J_H's user avatar
  • 28.9k
1 vote
Accepted

Event manager based on decorators

test_envent.py nit, typo in module name. ... transforms a function into an event quibble: Maybe "... into an event generator" modern type annotations ...
J_H's user avatar
  • 28.9k
1 vote

Multi-Client Socket Communication with Thread Pool in C++

I think include.h is a bad idea - it makes every compilation unit dependent on all the headers used by all the code. Instead, think about which headers are needed ...
Toby Speight's user avatar
  • 76.8k
1 vote
Accepted

HTTP routing with Mongoose

Unnecessary use of smart pointers You use std::unique_ptr twice, but both times it is unnecessary. In main(), you can just ...
G. Sliepen's user avatar
  • 58.3k
1 vote

Finding duplicates in given list of files

Some other points, besides to the already nice answers: Hashing chunks If you want to reduce the total IO / byte comparisons, you could store a hash of each of the chunks as list with the file. So ...
Rob Audenaerde's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible