People who code: we want your input. Take the Survey
11

I'm not a C++ developer, and can't comment on the details of the code. But I can comment on the test cases and the general style of the code. A good test should be enough to recreate the code from reading just the test cases. Especially when you get the task to make sure the code works under any circumstance. Successful test cases Let's have a look at your ...


9

C++ 17 Why limit yourself to C functions? DynamicTest(OutputType (*testfunc)(InputType), OutputType (*trustedfunc)(InputType)) I would declare this as: DynamicTest(std::function<OutputType(InputType)>&& testfunc, std::function<OutputType(InputType)>&& trustedfunc) Also the C++ versions for function declarations are easier to ...


9

Except under unusual circumstances, classes are things or entities -- hence the term objects -- while functions or methods are actions or operations. You want to name them accordingly. For that reason, Get_labels strikes me as an oddly named class. Based on what you've shown us, I might suggest the name Bounds as an alternative. A side benefit of that name ...


8

Parametric files It would be trivially easy to have Conference accept filenames as parameters to its constructor, and will make this more usable. Variable names Track should be lower-case. O is a poor choice of variable name for a list of reasons: It should be lowercase It looks the same as a zero Generally speaking, single-letter variable names are ...


8

A function that returns the largest value in a vector would certainly have to check if the vector is actually non-empty. You aren't handling that case and are just assuming "the first" element is the biggest...if there is no "first" element, your program will crash in Debug builds or invoke UB in Release builds. Also, were there ...


6

You haven't indicated the purpose for writing these implementations. The natural alternative would be to use Arrays.binarySearch unless this is purely for learning purposes. Testing Your test suite is far from exhaustive, testing that both methods can find the item at position 2 is very minimal (at the moment both implementations could simply always return ...


6

Some Concepts I'm not much experienced in the framework used but Unit Testing, Test Driven Development and Behavioral Driven Development are concepts that need to be understood well and then implemented properly. Unit Test Definition by Michael Feathers I've used these rules with a large number of teams. They encourage good design and rapid feedback and they ...


6

Unit tests are great, and perfectly suited to self-contained functions such as this. However, assert() is not a testing tool. It's more use as a kind of "magic comment" to tell our readers what we believe to be true (and sometimes to help optimise our code). One of the great problems of assert() is that its diagnostics are weak. On failure, it ...


5

Make the desired container type a template parameter You are duplicating a lot of code, when the only thing that changes is the type of container that your are returning. You should make the container type a template parameter, for example like so: template<template<class...> class Container = std::vector, class T> requires (!is_iterable<T>)...


5

Keep it simple Use the KISS principle, and don't make things more complicated than necessary. Using more language features should not be a goal in itself. Also, don't add more things in a class than necessary. Why do you keep track of dimension? Nothing inside the class makes use of it. The dimension is a property of PointType and VectorType, so it's already ...


5

Template vs. function parameters Template parameters should normally be used for things that affect the type of the result, but not for other things. The template parameter times does not affect the type of the result, so it can just be a regular function parameter: template<template<class...> class Container = std::vector, std::size_t dim, class T&...


5

A few things to consider / be careful of: Pass by reference (and probably an immutable one at that) - so you are not copying the vector AND you are showing that you are only using methods that don't have an effect of changing the vector. e.g int largest (std::vector<int> const & vec ) { Boundary cases (empty vector should give what value for ...


5

The problem here is the call to the new operator inside your code under test (cut). So the way to go is to inject this dependency into your cut. Of cause the (failed) implementation of the Java Singelton Pattern is a problem too. By looking at the API of the Date class we find that it is mutable (which raised lots of discussions when it was introduced). This ...


4

This is a decent improvement over your first posting. Let's start off with some things you are doing right. Your use of Decimal is correct. Many first attempts will incorrectly use double. Nice indentation. Most names are fairly good. Whereas many will over-abbreviate, you tend to make the names too long. Let's think of how an ATM should work. A ...


4

Line continuations Multi-line strings like this: intro = \ "DesmOEIS\n" \ "A tool for converting OEIS sequences to Desmos lists.\n" \ "\n" \ "Type id=<OEIS id> (without the brackets) to convert a sequence. \n" \ "Type help for a list of all valid commands. \n" \ "Type exit to close the ...


4

In a practical scenario, a good unit test should cover all edge cases. Hence, you should test the empty list, and you should test the cases where the largest element is at the beginning, at the end, and somewhere in the middle of the vector. There might be even more reasonable test-cases. There is, however, the possibility that you have been confronted with ...


4

Test-ability @Timothy Truckle and @slepic have both given you some good suggestions about how you can improve your test and the test-ability of your class. There are various other ways that could be used to make the class more testable, however the thing that struck me was that the LoggerService didn't seem to make a lot of sense. A Logging Service? There's ...


4

Application.py Your mock application has a few problems. There are also some improvements to be made regarding code style and structure. Bugs --isSorted and --getAll will currently not work with the spelling specified by the problem statement. @click.option('--issorted', help='...') @click.option('--getall', help='...') should become @click.option('--...


3

Ah, a fine Spec. Has been a while since I've used Hspec, but your tests seem reasonable. So, first of all: well done! There is one bit we should fix though, and you have identified it yourself: the property tests. QuickCheck's newtypes Creating any kind of number and then checking whether it's positive is a hassle, as half the numbers will get discarded per ...


3

Value Objects The following shows what most users would consider unexpected behaviour: from ccomplex import Complex a = Complex(5, 4) + Complex(3) b = a a.re = -a.re print(b) # "-8 + 4i" Values are usually considered to be immutable. Since Python uses objects to represent values, and objects have identity which can be shared, the best practice ...


3

Looks pretty good. I see you implemented modulus in mod. It's also called absolute value, and that's the name Python uses. If you implement __abs__, then Python's abs function can use it. Then abs(Complex(3, 4)) would give you 5.0. Just like Python's own abs(3 + 4j) does. Another useful one is __bool__, which lets you declare zero as false, as is standard in ...


3

Comment on Transaction DDL. While Microsoft does state that its presence indicates that the backend supports transactions, there is another reference (possibly outdated) discussing DBPROP_SUPPORTEDTXNDDL enum, where DBPROPVAL_TC_NONE value of Transaction DDL indicates that transactions are not supported. In fact, I have made a few test snippets for ...


3

Pick your framework You're learning new stuff, so your style will develop as you progress. While the code is still fresh, try to refactor as you go, so that the code moves towards a consistent style. If you want to move towards FluentAssertions, then try to use it for all of your assertions. Rather than this: // Fluent Assertions accountExpected.Should()....


3

Handling invalid input Instead of returning an array when inputs are invalid, throw exceptions and use throw to detect it in the tests. Avoid else when previous blocks have return statements The else can be eliminated since the block evaluated when value <= 0 has a return statement (or would throw an exception). Additionally, the switch statement can be ...


3

In-band error signalling return signal_data # ... # reports false if message fails to be received return False is problematic. You're forcing the caller of this code to understand that the return value has at least two different types: boolean or whatever "signal data" is. The Python way to approach this is to use exceptions. Rather than (say) re-...


3

First, here are some quick observations about your implementation: It does not handle faulty or malfunctioning cases: What if one of the services fails? What if one of the services responds quite slowly? It does not take advantage of concurrent async calls As I can see the artistsService call does not depend on the previous service call You can run them ...


3

Here are some ideas that may help you improve your code. Understand the purpose of CMake Many people misunderstand CMake as a "build system" but it is not. It is a tool for creating a build system. Generally speaking, this means that you describe the desired artifacts (executables to be compiled, tests to be compiled and run, documentation to be ...


3

I don't think you need to test everything around opening the input file, closing it, handling exceptions, etc. For the purpose of this task, I believe you want to test your logic, and trust that FileReader or FileInputStream etc just work. I would have a class that that can read the format of the dictionary (not provided, presumably this is ...


3

Unittests are (executable) documentation The name of a test method should read like a sentence from the requirements. Beginners should stick with the pattern suggested by Roi Osherove methodName_precondition_expectedResult() Keep AAA - Structure of test methods visible. Test Methods consist of three parts: Arrange Act Assert Others call it "given, ...


2

The tests are technically correct, but the value they have doesn't match the amount of time you spent on them. It looks like you're using class-based views, and in such case I'd expect LikeView and CategoryView in the routes should be called the same way as other views, ie. with .as_view(). If my assumption is correct, then your tests should at least catch ...


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