All Questions
Tagged with tdd or unit-testing
114 questions
43
votes
4
answers
7k
views
Rainfall challenge
About a year ago when I was applying to jobs for the first time, I had an interview at a company and they posed the following problem to me, which I preceded to bomb.
A year later I actually came up ...
28
votes
5
answers
4k
views
Automagic testing framework for VBA
Building on @RubberDuck's recommendations, I now have something I find... beautiful. I'm sure there's a couple of things left to polish - this site is about making great code out of good any code, ...
9
votes
2
answers
298
views
Hand Coded State Driven Lexical Analyzer in C With Unit Test Part A
This code review is presented in 3 questions due to the amount of code:
Part A (this question) contains the Lexical Analyzer and the main portion of the unit test code.
Part B contains the lower ...
7
votes
1
answer
1k
views
UTF-8 encoding/decoding
I have two functions, a collection of possible error codes, and a unit-testing framework.
The parsing of a character into its unary prefix and payload is handled by a few named functions and macros <...
5
votes
1
answer
93
views
Hand Coded State Driven Lexical Analyzer in C With Unit Test Part C
This review is presented in 3 questions due to the amount of code:
Part A contains the Lexical Analyzer and the main portion of the unit test code.
Part B contains the lower level unit tests called ...
25
votes
2
answers
5k
views
Go on, mock my IDE
Because of the coupling with the VBIDE API (the extensibility library for the VBA IDE), unit testing the rubberduck refactorings, inspections and quick-fixes has been pretty much impossible, at least ...
8
votes
1
answer
1k
views
Timing analysis of many test cases in Python
I am learning about timing analysis in Python. I used time module before it was pointed out that timeit module would be better ...
4
votes
1
answer
64
views
Hand Coded State Driven Lexical Analyzer in C With Unit Test Part B
This review is presented in 3 questions due to the amount of code:
Part A contains the Lexical Analyzer and the main portion of the unit test code.
Part B (this question) contains the lower level ...
3
votes
1
answer
176
views
Swap items of a linked list in pairs - revision 2
The first revision is available here and the code is available on GitHub. I modified the method reversePairs and added mSize to ...
2
votes
2
answers
95
views
Common Unit Testing Code – Follow Up
This question is a follow up question to the Common Unit Testing Code portion of my lexical analyzer questions.
My primary concern is the code in the header file and the C source file that implements ...
2
votes
1
answer
84
views
Swap items of a linked list in pairs - revision 3
Here is the source of the question.
Revision 1.
Revision 2.
When I started the second round of code review, I wanted to make sure that I had included all the possible input types. However, I ...
2
votes
1
answer
99
views
Android app class serialization
I am attempting to build an Android APP with the custom serializable class User. The public method Save is to save class ...
2
votes
0
answers
39
views
Testing the process of assigning offers to a customer 2
I asked this question earlier: Testing the process of assigning offers to a customer. Following on from the answerers comprehensive response. I have attempted it again. Please see the test code ...
21
votes
3
answers
2k
views
Writing better JUnit tests
I am using Spring Framework, Hibernate and JUnit. I am testing persisting of a UserEntity.
The UserEntity has the following associations:
ManyToMany - City
ManyToMany - ActivityCategory
ManyToOne -...
17
votes
3
answers
2k
views
ExactlyOne extension method
I often find in codebases something on the order of if (sprockets.Count() > 0) which is easily replaced with LINQ's ...
15
votes
3
answers
2k
views
Trading Card Game's Hand class and tests
As part of a Trading Card Game, I have created a Hand that will need to hold all cards that a player currently has in his hand. The code is built using Java 8.
The ...
12
votes
1
answer
377
views
BattleShip Grid: Classes and Tests
In my ongoing quest to demonstrate how VBA code can absolutely be object-oriented, I've started implementing a game of Battleship in pure VBA.
This is a rather large project, so I'll split the ...
12
votes
4
answers
13k
views
Align Strings for Output
I wrote a class which can format input so that it is properly aligned.
I'm interested in all suggestions (regarding structure, usability, style, naming, comments, etc).
I'm especially wondering ...
11
votes
3
answers
365
views
Secure ADODB: Unit of Work
I've been meaning to revisit this old code for a long time, and this week finally ended up doing it. The resulting code is on GitHub, and for full context and disclosure I wrote a blog article about ...
8
votes
3
answers
12k
views
Make WCF Service testable
I have WCF Service. It works fine and I want to have test coverage for it. Unit tests and acceptance.
The problem is the static class in the code. How is it ...
8
votes
1
answer
761
views
Are AVL trees equal?
I was inspired by this answer and decided to implement an AVL tree with the methods equals and hashCode as if I was asked to do ...
8
votes
2
answers
178
views
Generic Max() for Integer Types (including Boolean)
This is a follow-up to An Attempt at Creating Generic min()/max() for Fundamental Types.
What's Changed:
MIN() has been forsaken for the time being.
Mixed types ...
8
votes
1
answer
6k
views
Hypothetical SalesTax challenge
I have a small solution to the following hypothetical problem:
Basic sales tax is applicable at a rate of 10% on all goods, except
books, food, and medical products that are exempt. Import duty ...
6
votes
1
answer
157
views
Non-nested std::deque and std::list Generator Function for arithmetic_mean Function Testing in C++
This is a follow-up question for A non-nested test_vectors_generator Function for arithmetic_mean Function Testing in C++ and An arithmetic_mean Function For Various Type Arbitrary Nested Iterable ...
6
votes
1
answer
188
views
A Various Container Type Arbitrary Nested Iterable Generator Function Implementation in C++
This is a follow-up question for std::array and std::vector Type Arbitrary Nested Iterable Generator Functions Implementation in C++ and std::deque and std::list Type Arbitrary Nested Iterable ...
5
votes
1
answer
203
views
Testing the process of assigning offers to a customer
I asked a similar question yesterday, which was criticised because I posted the test without the supporting code. Therefore I deleted the question yesterday as it was not clear enough. I am now ...
5
votes
3
answers
3k
views
Implement strtod parsing
In this comment the OP wrote,
I am a newbie so i would like to know how would i parse the negetive numbers/arguments ?
In this answer @200_success showed an implementation using the strtod ...
4
votes
2
answers
276
views
Linked list implementation along with unit test - Round 2
Here is the link to the next round of code review: Linked list implementation along with unit test [Round 3]
Here's the link to the previous code review:
Linked list implementation along with unit ...
2
votes
1
answer
112
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 ...
1
vote
2
answers
88
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 ...
1
vote
1
answer
97
views
Swap items of a linked list in pairs - revision 4
Here is the source of the question.
The solution on GitHub.
Revision 1.
Revision 2.
Revision 3.
@200_success' suggestions from revision 3:
The iterator's ...
1
vote
0
answers
48
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 ...
1
vote
1
answer
59
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(), ...
31
votes
1
answer
4k
views
Unit Testing in VBA
Unit testing in VBA is... lacking. (What isn't lacking in VBA though?) Since I've become more interested in unit testing lately, I decided I needed something better than ...
30
votes
4
answers
3k
views
Just a lowly counter that turned out to be surprisingly complicated
While writing this review, I saw a need for a Counter object similar to Python's. It seemed like it would be easy to write such a class, but it turned out to be ...
28
votes
4
answers
15k
views
Unit-testing a controller in Ruby on Rails
I intend this to be a general question on writing an effective set of test cases for a controller action.
I include the following ingredients:
Ruby on Rails
RSpec: A testing framework. I considered ...
16
votes
4
answers
2k
views
Extensible and testable FizzBuzz
There seem no end to fizzbuzz implementations.
Something I rarely see is an implementation that's easy to extend with more name-divisor pairs.
Another thing that usually annoys me is the lack of ...
14
votes
4
answers
3k
views
Coin dispenser program
I've decided to go tech and learn a language. I have been reading Java for a week and here is my first attempt. I am making a habit to write JUnit test cases so that I start on correct path. Here is ...
14
votes
2
answers
5k
views
Repository and Controller tests
Lately I have been researching how to best unit test an EF repository and given a properly tested repository, what to test in the controller.
My research did not reveal many sound examples or ...
12
votes
1
answer
2k
views
Flatten an array of integers in Python
The goal is to flatten an array of nested arrays of integers.
For example [1, [2], [3, [4]]] should return [1, 2, 3, 4]
I'm ...
12
votes
1
answer
2k
views
Minimal C++ Unit Test Framework
I've written a minimal unit test framework. The goal was to allow assertions of booleans, for equality and catched exceptions. Two things are bugging the most. That assertions have to rely on macros ...
11
votes
1
answer
333
views
Science Fiction Wall of Fame (Shame?)
I have a few of hobbies, one is reading science fiction and fantasy and another is coding solutions. I thought I might have a chance to combine both hobbies on this project.
I have well over 1500 ...
10
votes
2
answers
2k
views
Verhoeff check digit algorithm
A recent question on credit card validation here on Code Review, led me down a dark rabbit hole of check digit algorithms. I took a stop at the Verhoeff algorithm and tried to implement it myself.
...
10
votes
2
answers
8k
views
Converting Morse Code
Challenge
Write a program which reads a file containing Morse Code and outputs the conversion.
Specifications
The first argument is a path to a file.
The file contains multiple lines.
Each line ...
10
votes
2
answers
1k
views
Unit Testing - A Better Solution
Following-up on the Automagic testing framework for VBA review, I've refactored much of the TestEngine static class, and introduced a ...
10
votes
1
answer
1k
views
Generate iCalendar .ics files with events for astrological aspects
I'm relatively new to Python, coming from a deep C++ background. I'm mostly looking for feedback on how to make my code more idiomatic/pythonic, but I would welcome and appreciate any and all other ...
10
votes
1
answer
5k
views
TDD - Kata - String Calculator
This is my first TDD Kata I've done and I'd appreciate it if someone could review it.
String Calculator
Create a simple String calculator with a method int Add(string
numbers)
The ...
9
votes
1
answer
3k
views
Unit-testing the importing of data into a database
I have a functionality that imports data into a database, based on an Excel workbook and some meta data (both user-supplied). The functionality implements interface ...
8
votes
1
answer
4k
views
Linked list implementation along with unit test
I've already made all the changes suggested here. Here is the link for round 2: Linked list implementation along with unit test [Round 2]
I want to see how other people think of my code, so here it ...
8
votes
1
answer
1k
views
Alternate letters to UpperCase
As an exercise I repeated this Java question, but in Go: Convert string to mixed case
The objective is for every second letter to be converted to uppercase.
Go string processing is relatively new to ...