Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix for Gherkin's localization #63

Copy link
Copy link
@demidovsursu

Description

@demidovsursu
Issue body actions

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;
}

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.