Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
2
votes
1answer
14 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 ...
3
votes
1answer
33 views
Unit-testing an RSS feed parser
I'm working on a class to parse RSS feeds using SyndicationFeed. (related to Downloading data using HttpClient). I'm trying to write this so it can be unit-tested, ...
3
votes
1answer
49 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 ...
4
votes
1answer
102 views
White box input stream for creating test scenarios
I need to test a specialized input stream class that takes input from a TCP/IP network connection. I particularly need to ensure that the blocking and availability behavior is correct.
To help me ...
-2
votes
0answers
33 views
Two unit tests, one taking a PieData, another taking a Map<String,Integer>
I have two similar test methods:
...
5
votes
1answer
31 views
Testing boto connection
I am writing a unit test to be sure the code can connect to aws via boto, since I will be putting the credentials in place via some other process than code deployment. So far, I've only figured out ...
11
votes
2answers
59 views
Unit testing with a singly linked list
To hone my skills with C++11, I'm implementing a singly-linked list based on the requirements I found at this link.
I've implemented code that supports the following subset of requirements from the ...
1
vote
0answers
21 views
Monoalphatic and Polialphabetic cipher in Ruby
This code encrypts a text with mono-alphabetic and poli-alphabetic substitutions ciphers.
For further info see:
Mono-alphabetic/Caesar Cipher
Poli-alphabetic cipher
:
...
16
votes
2answers
4k 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 ...
10
votes
1answer
155 views
Robot toy simulator
I have already flunked the test with this code so don't feel bad for cheating any employer. I didn't get any feedback though just wondering what could have gone wrong.
You don't need to get into the ...
-1
votes
0answers
47 views
Reuse code in unit tests
Currently we are trying to implement some unit testing on our services. In the below service an order is created and a audit registration is made about the creation of an order. When writing the two ...
4
votes
1answer
57 views
Unit testing a CharGrid
I wrote NUnit tests for class CharGrid from this homework assignment.
My goal here is DRY: I want to keep the testing code as short and simple as possible. In addition, want to run every test ...
3
votes
1answer
82 views
Naming request for a class to return a different value every so often
I have a class that I'm trying to determine a good name for. I don't know if this concept comes up a lot in programming or not, but I'm wondering if I can get some suggestions for a good name for the ...
3
votes
1answer
38 views
Arrow test Ruby gem
I wrote my first Ruby gem, which is for testing code in the shortest way possible.
Here's a usage example:
require 'arrow_test'
1 + 1 # -> 3
arrow_test
The ...
2
votes
1answer
91 views
Find pairs in an integer array whose sum == 10
I'm practicing for technical interviews and I'm looking for ways to improve my answers/code. Please point out the flaws you see and how I can make this better.
Task:
Find pairs in an integer array ...
2
votes
1answer
48 views
Testing that a class with a lot of data is inserted into a repository
I have a legacy system with a class with a lot of data. I am creating a web service that inserts a new claimant into that system for a contractor. I can not refactor the claimant object.
I need help ...
3
votes
4answers
83 views
Are the words isomorph?
Are the words isomorphs? (Code-Golf)
This is my non-golfed, readable and linear (quasi-linear?) in complexity take of the above problem. For completeness I include the description:
Two words are ...
0
votes
0answers
45 views
Address validation unit test
This is an example of a unit test I've just written for an ASP.NET controller action to test whether the model's RequiresClassification flag is set to true.
The ...
7
votes
6answers
157 views
Super Market Checkout Pricing Strategies
I saw this question and thought it looked like a great opportunity to try my hand at the Strategy Pattern. I've never used it before, but I think I did pretty well. Did I?
The code below can also be ...
4
votes
0answers
26 views
Basic declarative style to rotate and crop an image array
I wrote a couple of basic Clojure functions (practicing a declarative style) and I was looking to get some feedback on them. You can see all the code here. Is there anything I could improve on to ...
2
votes
1answer
67 views
TDD: String Calculator Kata
String Calculator
Create a simple String calculator with a method int Add(string numbers).
The method can take 0, 1 or 2 numbers, and will return ...
4
votes
2answers
74 views
TDD - String Calculator Kata
Would really appreciate it if someone could please review my String Calculator TDD KATA.
String Calculator
Create a simple String calculator with a ...
1
vote
1answer
48 views
Angular filter to format temperature
Below is a basic filter I created with Angular that does temperature conversion. I'd like to get thoughts on how to improve this code from both an Angular perspective and a general JS perspective.
...
3
votes
3answers
150 views
TDD Supermarket Pricing Kata
I have done the supermarket pricing kata in TDD style and I would appreciate it if someone could review it for me.
Kata:
"...checkout that calculates the total price of a number of items. In
...
1
vote
1answer
63 views
Creating various types of menus using dependency injection
I am here to discuss what are the possible improvement can be made in order to make the following code covering all the principles of programming paradigm ( SOLID , DRY ...etc ). Basically, I am ...
18
votes
3answers
2k views
“The python that ate a calculator”
In a YouTube video I watched, the speaker said it is important to know how to calculate between numbers of different bases; i.e. two, ten, and sixteen. I was then inspired to write a small C program ...
4
votes
1answer
40 views
Javascript static and prototype mocking
I'm writing unit-tests for my Node.js/Express application with REST endpoints which retrieve stuff via Mongoose from db. Since I'm testing only route functions I want to mock Mongoose by providing ...
0
votes
1answer
47 views
Testing console.log output using assert.deepEqual in NodeJS
I'm new to testing and NodeJS and I'd like to test the output in console.log using assert.deepEqual to test whether or not the result has correct data.
For ...
3
votes
2answers
168 views
JUnit testing for Calculator in Java
I made a simple calculator.
I would also like to write some simple unit tests for my CalculatorEngine class. I had to make some of my ...
2
votes
3answers
323 views
String Calculator Kata Code in TDD style
I have done the following kata in TDD style and would appreciate it if someone could review my code and my tests.
String Calculator
Create a simple ...
0
votes
0answers
64 views
Unit testing Socket communication with a race condition
I've developed a library that wraps TcpClient TcplListener objects into the concept of ...
7
votes
2answers
114 views
Traversing binary trees through and through
Given a binary tree, it's quite common to perform some operation on all nodes while traversing pre-order, in-order, post-order or level-order, depending on the task at hand. For example you might want ...
1
vote
1answer
36 views
Testing class that transforms JSON into a spreadsheet
I am creating unit tests but the class uses objects that have long JSON. What can I do to improve the readability of this?
In tests, only insert those JSON really needed for the test. The class I ...
1
vote
2answers
55 views
Unit Testing of parser method using py.test
This is my first time using py.test. All feedback for this test case is much appreciated.
...
6
votes
2answers
119 views
Renaming PDF files based on given rules in a text file
I'm learing Python by writing a program to solve some housekeeping I do weekly, namely renaming PDF files according to rules given in a text file.
My end goal is to have idiomatic Python, with full ...
5
votes
1answer
63 views
Implementation of the change making algorithm
I wrote a set of python classes for solving the change making problem, in various forms.
Given the coin denominations and values:
Find all possible ways of making change.
Find a best way ...
5
votes
1answer
70 views
Safe cracker string with all combinations
Imagine a safe with a 4-digit code, and accepting a continuous stream of code entries, such that when the 4 digits are seen in the right sequence, the safe opens. Generate a short string that ...
4
votes
1answer
58 views
Find minimum number of coins (count and list of coins too)
For a given set of denominations, you are asked to find the minimum number of coins with which a given amount of money can be paid. Assume that you can use as many coins of a particular ...
5
votes
2answers
256 views
Longest substring with unique characters
Find the length of the longest substring without repeating characters
Any comments on my code?
...
3
votes
2answers
76 views
Resource caching in Java with soft references
I'd like to cache some heavy resources locally. The goal of this implementation is to have be able to load resources for an unknown amount of time and then keep them in memory and finally evict them ...
2
votes
1answer
18 views
Simplified doctest
The doctest module seemed easy to implement so I decided to write a simpler version of it.
my_doctest.py
...
7
votes
2answers
265 views
A (late) Simple Calculator
As I was looking through my past questions, I noticed my really old calculator question (here and here). Considering it looked like a huge mess, I decided to rewrite it. Coincidentally, the April 2015 ...
7
votes
3answers
154 views
Understanding my permalink service tests
I started writing unit tests cases recently. For now, I created only "perfect case" where there is no error. However, the test seems to me difficult to maintain and difficult to understand.
How can I ...
10
votes
1answer
225 views
Rendering an HTML form based on a specification in a string
Here's a brief explanation of my method:
Provide a string and parse it to HTML code respecting a specific format.
The accepted format is:
For dropdown menu : Test DropDown~Select:Options1; ...
3
votes
1answer
76 views
Integer ID pool
I would really appreciate some feedback on the code I wrote to solve the following problem:
Design an IdManager.
IdManager manages a pool of integer ids. (from 1 to n). It should
provide ...
11
votes
4answers
237 views
TDD svino Problem #4 - largest value from concatenated integers?
From this blog post:
Write a function that given a list of non negative integers, arranges them such that they form the largest possible number. For example, given [50, 2, 1, 9], the largest ...
6
votes
1answer
88 views
Java 8 unit test for third-party data feeds
Use Case
I have a service that does processing of records from multiple third-party feeds. The steps are generally identical for each feed, but each feed is populated in a different location on an ...
5
votes
3answers
154 views
Random letter test
My first test (randomUpperCaseLetter) checks if the returned random letter is an uppercase ASCII one. The second one (...
1
vote
2answers
198 views
Accessing argparse arguments from the class
I have the following sample code running unit tests:
...
4
votes
0answers
71 views
Is this test sane? I may have re-invented the wheel on how to test that a method does not block
I have an Android service which must offload a task to a different thread but schedule the response callback unto the calling thread. After much thinking I came up with this code:
...