mirror of
https://gitlab.com/square-game-liberation-front/F.E.I.S.git
synced 2025-02-28 23:41:33 +01:00
Add whereami test program
This commit is contained in:
parent
921ccb9cf1
commit
429feed81b
@ -39,6 +39,14 @@ executable(
|
|||||||
include_directories: inc,
|
include_directories: inc,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
executable(
|
||||||
|
'nowide+whereami',
|
||||||
|
'nowide+whereami.cpp',
|
||||||
|
include_sources['whereami'],
|
||||||
|
dependencies: deps,
|
||||||
|
include_directories: inc,
|
||||||
|
)
|
||||||
|
|
||||||
executable(
|
executable(
|
||||||
'scrollwheel',
|
'scrollwheel',
|
||||||
'scrollwheel.cpp',
|
'scrollwheel.cpp',
|
||||||
|
41
tests/nowide+whereami.cpp
Normal file
41
tests/nowide+whereami.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#include <cstddef>
|
||||||
|
#include <cstring>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <nowide/args.hpp>
|
||||||
|
#include <nowide/fstream.hpp>
|
||||||
|
#include <nowide/iostream.hpp>
|
||||||
|
#include <whereami++.hpp>
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void check_file(T& file) {
|
||||||
|
if (not file) {
|
||||||
|
nowide::cerr << "Can't open file" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::size_t total_lines = 0;
|
||||||
|
while (file) {
|
||||||
|
if(file.get() == '\n') {
|
||||||
|
total_lines++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nowide::cout << "File has " << total_lines << " lines" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::string executable_folder = whereami::executable_dir();
|
||||||
|
nowide::cout << "whereami::executable_dir() = " << executable_folder << std::endl;
|
||||||
|
|
||||||
|
auto u8string = std::u8string(executable_folder.begin(), executable_folder.end());
|
||||||
|
nowide::cout << "std::u8string{_)} = " << reinterpret_cast<const char*>(u8string.c_str()) << std::endl;
|
||||||
|
|
||||||
|
std::filesystem::path u8path{u8string};
|
||||||
|
nowide::cout << "std::filesystem::path{_} = " << u8path << std::endl;
|
||||||
|
|
||||||
|
nowide::cout << "nowide::ifstream{_} : " << std::endl;
|
||||||
|
nowide::ifstream file_from_path(u8path / "test_file.txt");
|
||||||
|
check_file(file_from_path);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user