You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> This approach is used by this project's ```tests``` directory.
36
-
37
34
Nonetheless, I highly recommend making use of a second, cleaner approach where you don't have to directly include the library as one of your project's subdirectories:
> You can optionally change the value of the ```CPP_SAFE_IO``` variable before the ```FetchContent_MakeAvailable()``` call, if you wish so, since it won't be overwritten and it'll show up when building the project.
65
62
63
+
> [!IMPORTANT]
64
+
> If you want to use ```Windows```'s ```conio.h``` header file's functions in this library, you should set the ```INCLUDE_CONIO_FOR_IO``` option to ```ON```, since it's automatically off. You can try something like this on your project's main ```CMakeLists.txt```:
65
+
>```
66
+
> option(INCLUDE_CONIO_FOR_IO "Flag for including the conio.h header file" ON)
67
+
> ```
68
+
69
+
66
70
## How to use
67
71
68
72
You only need to include the ```cppsafeio.h``` header file. Henceforth, all of the library's functions will be available inside of the ```CppSafeIO``` namespace, similarly to the ```std``` namespace of the ```C++ Standard Library```. Here's a simple example showcasing a program that won't exit until the ```Enter``` key is pressed.
@@ -96,7 +100,17 @@ int main()
96
100
* ```bool parseYesNoInput()```: Overloaded version of the previous function with both ```y``` and ```n``` as yesChar and noChar, respectively.
97
101
* ```std::string getInputLine():``` gets all entered input until a line break, as a ```std::string```.
98
102
99
-
## Testing
103
+
## Building & Testing
104
+
105
+
You can also just build and test the library independently from your projects, here's an example using ```bash``` in the library's directory:
As you can see, ```CMake``` is used to build the project and ```CTest``` to run the automated tests (the ```CppSafeIO-AutomatedTests``` executable)!
100
112
101
113
> [!TIP]
102
-
> You can test this library's functions in the ```tests``` subdirectory.
114
+
> If you wish to test out this library's functions, you can run the ```CppSafeIO-Tests``` executable. If it doesn't throw any exceptions or show any anomalies while getting input or cleaning output, then it should be working properly.
115
+
116
+
*Both of these tests' source code are available on the ```tests``` directory.*
0 commit comments