tests: portable find_data()

pull/587/head
nick black 4 years ago
parent ed548ab590
commit cbf46402f8
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -5,23 +5,22 @@
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <limits.h>
#include <climits>
#include <termios.h>
#include <filesystem>
#include <langinfo.h>
#include "version.h"
#include "main.h"
static const char* datadir = NOTCURSES_SHARE;
char* find_data(const char* datum){
char* path = (char*)malloc(strlen(datadir) + 1 + strlen(datum) + 1);
strcpy(path, datadir);
strcat(path, "/");
strcat(path, datum);
return path;
auto find_data(const char* datum) -> char* {
std::filesystem::path p = datadir;
p /= datum;
return strdup(p.c_str());
}
bool enforce_utf8(void){
auto enforce_utf8() -> bool {
char* enc = nl_langinfo(CODESET);
if(!enc){
return false;
@ -75,14 +74,14 @@ public:
for(; *argv_in; ++argv_in)
if(strncmp(*argv_in, "--dt-", strlen("--dt-")) != 0)
vec.push_back(*argv_in);
vec.push_back(NULL);
vec.push_back(nullptr);
}
int argc() { return static_cast<int>(vec.size()) - 1; }
const char** argv() { return &vec[0]; } // Note: non-const char **:
auto argc() -> int { return static_cast<int>(vec.size()) - 1; }
auto argv() -> const char** { return &vec[0]; }
};
int main(int argc, const char **argv){
auto main(int argc, const char **argv) -> int {
if(!setlocale(LC_ALL, "")){
std::cerr << "Coudln't set locale based on user preferences!" << std::endl;
return EXIT_FAILURE;

@ -72,7 +72,7 @@ TEST_CASE("NotcursesBase") {
int maxx, maxy;
notcurses_term_dim_yx(nc_, &maxy, &maxx);
auto total = maxx * maxy;
struct ncplane** planes = new struct ncplane*[total];
auto planes = new struct ncplane*[total];
int* planesecrets = new int[total];
for(int y = 0 ; y < maxy ; ++y){
for(int x = 0 ; x < maxx ; ++x){

Loading…
Cancel
Save