Coder Social home page Coder Social logo

xtest's People

Contributors

joshiayush avatar panquesito7 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

xtest's Issues

`ParseFlagValue()` returns `true` for non-value arguments when value arguments are used

Description

Currently while debugging, a bug has been come out where different flags are messing up with the algorithm. For example, flag nameshuffle is messing up with the algorithm when flag --color=no is used; ParseFlagValue() returns true for flag name shuffle when --color=no is used this is because of the statement *flag_end == '\0' in ParseFlagValue(). This is a bug in ParseFlagValue() and needs to be fixed.

Solution

A solution is to write a custom algorithm that will find the flag value in the given flag while also taking into account if the value is defined optional or not.

xtest/xtest/xtest.cc

Lines 483 to 501 in 5a06d39

static const std::string ParseFlagValue(const char* const flag,
const char* flag_name,
bool def_optional) {
if (flag == nullptr || flag_name == nullptr)
return std::string();
uint8_t preffix_len = ValidFlagPreffixLength(flag);
if (preffix_len == 0)
return std::string();
const char* flag_end = flag + (preffix_len + std::strlen(flag_name) + 1);
if (def_optional && *flag_end == '\0')
return "true";
if (*flag_end != '=')
return std::string();
return ++flag_end;
}

Replacing this fairly simple algorithm with a more robust one might help in solving this bug. I'll upload a more robust algorithm once I'll get time for it.

Capture output stream (stdout/stderr)

At the moment, we don't have any API that can also capture the output streams (stdout/stderr), so even to test our own xtest API we have to use the redirector API that we have inside of our tests which is not completely efficient. So, what I have decided to do is to implement a CapturedStream API similar to the one that googletest uses.

Problems with RedirectorContext:

  • We have to explicitly pass the type of the stream we want to capture.
  • We have to manually replace the stream file with our own context buffer.
  • We also have to restore the stream manually.

What googletest have for us:

  • Simplicity; (following example is taken from the cjson library).

    testing::internal::CaptureStdout();
    PrintSstream(&sstream, FALSE);
    std::string stdout_output = testing::internal::GetCapturedStdout();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.