Giter VIP home page Giter VIP logo

cpp-coding-challenge's Introduction

C++ Coding Challenge

Test Execution Status
build_and_test

This is my rather quick TDD implementation of the coding challenge below.
It features:

  • Make a File to build the code from the console
  • Unite Test
  • The actual implementation
  • GitHub Action CI Pipeline
----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----

        Specify and implement an interface to interpolate variables into
        a format string.  In the format string, variables are represented
        by a percentage sign followed by a variable name in parentheses.

        The interpolation interface needs only support string variables.

        The code must be valid C++98 (!) and compile without additional
        library dependencies besides the STL.

        Example:

        Given the variables

          adj = "quick"
          color = "brown"

        and the format string

          "The %(adj) %(color) fox jumps over the lazy dog"

        the result after interpolation should be

          "The quick brown fox jumps over the lazy dog"

---->8---->8---->8---->8---->8---->8---->8---->8---->8---->8---->8---->8---->8----

Please do not use this code for more modern projects as there is an implementation (std::format) in the standard library:

https://en.cppreference.com/w/cpp/utility/format/format

How to Run

Notice: I have developed this on linux/ubuntu, in theory the code should run fine on windows but I have not checked that. What probably need to be changed slightly are some path in the Makefile.

compile a clean and run the tests

make clean test

Example Output:

rm -rf ./src/main.o ./src/stringUtilityTests.o ./src/stringUtility.o a.out
g++ -std=c++98 -Wall -Wextra -pedantic -I./include  -I./include -o src/stringUtilityTests.o -c src/stringUtilityTests.cpp 
g++ -std=c++98 -Wall -Wextra -pedantic -I./include  -I./include -o src/main.o -c src/main.cpp 
g++ -std=c++98 -Wall -Wextra -pedantic -I./include  -I./include -o src/stringUtility.o -c src/stringUtility.cpp 
g++  src/stringUtilityTests.o src/main.o src/stringUtility.o -o a.out
./a.out
Running tests ...
Test-Case : test_polymorphism                           :       Pass
Test-Case : test_interpolate_with_single_value          :       Pass
Test-Case : test_interpolate_with_two_values            :       Pass
Test-Case : test_interpolate_with_duplicate_values      :       Pass
Test-Case : test_interpolate_with_extra_values          :       Pass
Test-Case : test_interpolate_with_missing_values        :       Pass
...all tests passed

cpp-coding-challenge's People

Contributors

felix-quehl avatar

Stargazers

 avatar

Watchers

 avatar

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.