Skip to content

fillmore-labs/cpp-sample

Repository files navigation

Fillmore Labs C++ Sample

Test Coverage License

Experiment in setting up a C++ build pipeline.

Purpose

This code is a simple FizzBuzz implementation, to play around with a C++17 build pipeline.

Running

Prerequisites

You need Bazelisk installed, with HomeBrew just use brew install bazelisk.

Tests

To run all tests, use

bazel test //test/...

Main App

Run the app with

bazel run //main:cpp-sample

or, for the alternate strategy (same result):

bazel run //main:cpp-sample-alt

Dependency Inversion Principle

This code demonstrates the application of the dependency inversion principle. Naively, one would simply make the main programm dependent on the concrete implementation of the transformation strategy. Here, we simply let the main programm own the interface, making it independent of the implementation and therefore the strategy exchangable.

Dependencies of //main:main
bazel query 'filter("^//", kind("source file", deps(//main:main)))'
//main:fizzbuzz.h
//main:main.cc

Then, to put everything together, cpp-sample.cc or cpp-sample-alt.cc pull in the concrete implementaion making a runnable application:

Dependencies of //main:cpp-sample
bazel query 'filter("^//", kind("source file", deps(//main:cpp-sample)))'
//lib:fizzbuzz.cc
//main:fizzbuzz.h
//main:main.cc
Dependencies of //main:cpp-sample-alt
bazel query 'filter("^//", kind("source file", deps(//main:cpp-sample-alt)))'
//lib_alt:fizzbuzz.cc
//main:fizzbuzz.h
//main:main.cc

The tests work the same way:

Dependencies of //test:fizzbuzz-test
bazel query 'filter("^//", kind("source file", deps(//test:fizzbuzz-test)))'
//lib:fizzbuzz.cc
//main:fizzbuzz.h
//test:fizzbuzz-test.cc
Dependencies of //test:fizzbuzz-test-alt
bazel query 'filter("^//", kind("source file", deps(//test:fizzbuzz-test-alt)))'
//lib_alt:fizzbuzz.cc
//main:fizzbuzz.h
//test:fizzbuzz-test.cc

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published