Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Gherkin's localization #63

Open
demidovsursu opened this issue Aug 12, 2021 · 0 comments
Open

Fix for Gherkin's localization #63

demidovsursu opened this issue Aug 12, 2021 · 0 comments

Comments

@demidovsursu
Copy link

I try to use .feature files with the language option and found 2 bugs.

  1. In GSteps.h need use "type" not "keyword" because "keyword" contains localized word.
    std::string keyword = children["type"];
  2. The function read_data in GUnit/Detail/FileUtils.h read chars from utf8 files.
    I fixed this bug using UnicodeUtilities_read_code_point_from_utf8_source from gherkin-c library.
extern "C" {
typedef struct Utf8Source Utf8Source;
long UnicodeUtilities_read_code_point_from_utf8_source(Utf8Source* utf8_source);
Utf8Source* FileUtf8Source_new(FILE* file);
unsigned char Utf8Source_read(Utf8Source* utf8_source);
void Utf8Source_delete(Utf8Source* utf8_source);
}

inline std::wstring read_file(const std::string &feature) {
  FILE* file = fopen(feature.c_str(), "rb");
  if (!file) {
    throw std::runtime_error("File \"" + feature + "\" not found!");
  }
  std::wstring r;
  Utf8Source* utf8_source = FileUtf8Source_new(file);
  for(;;) {
    long code = UnicodeUtilities_read_code_point_from_utf8_source(utf8_source);
    if (code == WEOF) break;
    r+=(wchar_t)code;
  }
  Utf8Source_delete(utf8_source);
  fclose(file);
  return r;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant