Hi guys,
I just wrote my solution for the raindrops exercise in the C++ track. Please see below my solution, test error example in the Exercism editor and my local tests results. If anyone could help point me in the right direction about why they’re failing after submission I’d appreciate it
Example of online editor error upon submission
In file included from /tmp/raindrops/raindrops_test.cpp:3: /tmp/raindrops/raindrops_test.cpp: In function 'void ____C_A_T_C_H____T_E_S_T____0()': /tmp/raindrops/raindrops_test.cpp:10:31: error: 'convert' is not a member of 'raindrops' 10 | REQUIRE("1" == raindrops::convert(1)); | ^~~~~~~
Running the tests locally
[main] Building folder: raindrops
[build] Starting build
[proc] Executing command: /opt/homebrew/bin/cmake --build /Users/mitch/Exercism/cpp/raindrops/build --config Debug --target all -j 14 --
[build] [ 25%] Building CXX object CMakeFiles/raindrops.dir/raindrops_test.cpp.o
[build] [ 50%] Linking CXX executable raindrops
[build] [100%] Built target raindrops
[build] ===============================================================================
[build] All tests passed (18 assertions in 18 test cases)
[build]
[build] [100%] Built target test_raindrops
[driver] Build completed: 00:00:00.825
[build] Build finished with exit code 0
My solution
#include "raindrops.h"
#include <string>
namespace raindrops {
std::string convert (int number) {
std::string sounds = "";
if (number % 3 == 0) {
sounds = sounds + "Pling";
}
if (number % 5 == 0) {
sounds = sounds + "Plang";
}
if (number % 7 == 0) {
sounds = sounds + "Plong";
}
if (sounds == "") {
sounds = std::to_string(number);
}
return sounds;
}
}