Skip to content

Project · C++ Programming (modern C++ and DSA)

Project: a UPI statement analyser built with CMake

Projectexpert· about 8 hours· 7 steps

The brief

Build a command-line tool that reads a month of UPI payments from a CSV file and prints a spending report: totals by category in Indian digit grouping (Rs 1,23,456.78), failed payments, bad lines with their line numbers, and the top merchants. It is a real CMake project with a library, a program and tests run by ctest.

Why it matters

Fintech and banking teams in India (payment apps, bank statement analysers, expense trackers, reconciliation tools) parse CSV statements like this every day. The way it is built is the way C++ teams work: money in integer paise, a library with unit tests, CMake so it builds the same on every machine, and ctest in CI.

Skills you practise

  • CMake targets and ctest
  • std::string_view and std::optional
  • Indian digit grouping
  • std::ifstream and exceptions
  • std::map and structured bindings
  • lambdas with std::sort
  • std::async and futures

You need

  • g++ 11 or newer (MinGW-w64 via MSYS2 on Windows, build-essential on Ubuntu, Xcode command line tools on macOS, where g++ runs Apple clang)
  • CMake 3.20 or newer (cmake --version), with Make or Ninja; on Windows MSYS2 (pacman -S mingw-w64-ucrt-x86_64-cmake) or the Visual Studio generator
  • A bash shell for the commands (Git Bash on Windows, or WSL); with the Visual Studio generator programs are in build/Debug/ and ctest needs -C Debug

What you will have at the end

A CMake project (txn.h/.cpp, main.cpp, two test programs, CMakeLists.txt) that builds a UPI statement report tool, with every test passing under ctest in Debug and Release.

How it is marked (rubric, 100 points)
Correct reportEvery check passes: amounts in paise, Indian grouping, skipped line numbers, category totals, top merchants and the matching parallel total.35
Tests and buildTwo test programs registered with ctest, passing in Debug and Release; warnings on and clean.25
Modern, safe C++string_view for parsing, optional for "no value", exceptions only for real errors, no double for money, no data race.25
Readable projectClear names, small functions, a short README with the build and run commands.15

0/7 steps done

Step 1 of 7

A CMake project with a library, a program and tests

cmake configures the project and builds upi_core, upi_report and txn_tests with no warnings.

Put all six files in one folder. In CMakeLists.txt, make a library upi_core from txn.cpp, then the program upi_report and the test program txn_tests, each linked to upi_core. Turn warnings on for every target (-Wall -Wextra -Wpedantic, or /W4 for MSVC). Call enable_testing() and register the test program with add_test, so ctest can run it. The stubs already compile; this step is only about the build.

add_library(upi_core txn.cpp)
target_include_directories(upi_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

add_executable(upi_report main.cpp)
target_link_libraries(upi_report PRIVATE upi_core)

add_executable(txn_tests txn_test.cpp)
target_link_libraries(txn_tests PRIVATE upi_core)

foreach(t upi_core upi_report txn_tests)
  if(MSVC)
    target_compile_options(${t} PRIVATE /W4)
  else()
    target_compile_options(${t} PRIVATE -Wall -Wextra -Wpedantic)
  endif()
endforeach()

enable_testing()
add_test(NAME txn_tests COMMAND txn_tests)
Target-based CMake: each target gets its own sources, links and options.
Run this on your machine, then paste the output below
$ cmake -S . -B build; cmake --build build --clean-first
Your notes: CMakeLists.txt, txn.h, txn.cpp, main.cpp, txn_test.cpp

Write down each command you ran. It goes into your project summary.