Programming Leftovers
-
Deride, a generator of mock objects for unit testing | Mardy
If you have been writing C++ classes for mocking out your C or C++ dependencies, you know how tedious it is. I generally write small classes with just a handful of methods, so it's generally bearable, but when using third-party code I'm usually not that lucky. If the dependency is a C library this becomes especially tricky, both because they might be larger than what you can handle, and both because the lack of an object-oriented design might not offer you an easy solution to store the mock object data.
But fear no more, Deride is here!
I won't spend too many words describing it, since you can read its description from the link above, where you will also find some example code. More examples, by the way, can be found in the example/ folder in the code repository, where you can see how it can be used to mock both pure C++ and QObject-based classes, and C libraries.
What is most important for me to say now, is that the project is in alpha state, meaning that I've tried it on a handful of header files only; it's highly likely that it will not work on many real-life scenarios, and if that happens I warmly invite you to inform me by filing a bug report providing the include file that was not properly processed.
I leave you with a short example of a unit test, written using Deride. The class under test is called Stable, and internally it uses objects of type Horse, that we decided to mock. We used Deride to generate the mocked implementation and a MockHorse class which can be used to control the mocked objects. When building the test, we won't link against the original horse.cpp, but we'll only use the original horse.h; the implementation will be found in mock_horse.cpp, generated by Deride. And in the corresponding mock_horse.h file we'll find the MockHorse class with all the on
Called() hooks which we can use to install our callbacks (either to reimplement the object behaviour, or to just be notified on when its methods are called). -
React Static: A Progressive Data Agnostic Open-source Static Site Generator
React-Static is a fast, lightweight, and powerful progressive static site generator based on React and its ecosystem. It resembles the simplicity and developer experience you're used to in tools like Create React App and has been carefully designed for performance, flexibility, and user/developer experience.
-
Dirk Eddelbuettel: RcppSpdlog 0.0.9 on CRAN: Extended Usability and New Upstream
A brand-new version 0.0.9 of RcppSpdlog got onto CRAN overnight. RcppSpdlog bundles spdlog, a wonderful header-only C++ logging library with all the bells and whistles you would want that was written by Gabi Melman, and also includes fmt by Victor Zverovich.
This release contains two changes. First, we extend usability by offering both a set of simple R functions for logging from R, and a matching set of functions at the C++ level that are directly callable (and exported) from this package (so that client packages do not need to compile). Both these changes are described (as sections seven and eight) in the vignette. Second, while we were working on this Gabi released version 1.11.0 upstream so we included this as well.
-
Game of Trees 0.78 released
Version 0.78 of Game of Trees has been released (and the port updated): [...]
-
Map any region in the world with R – Part II: Obtaining the coordinates
This is the second part of the series to create a map of any region of the world with R.
-
RC Week 7: Four habits to improve as a programmer
Seven weeks down, five weeks to go! It's flying by quickly. On the one hand, I want it to last forever. On the other hand, I know it can't, and I'm looking forward to talking to coworkers again at my day job when I go back. RC has given me a renewed appreciation for what I get at my job. More on that in December, though.
For now: RC, and the goals I have while I'm here. Instead of focusing on what I did this week, I'm going to use this post to talk about how I want to improve as a programmer.
-
Pocket Operator add-on board launched for $99
CrowdSupply recently launched the Pocket Integrator, which is an add-on board for the compact programmable synthesizer/sequencer Pocket Operator released some years ago. This add-on board allows the user to control the time, tempo and also send MIDI & sync to the PO in real time.