Skip to content

ivanovkirilg/diff-tool-skeleton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Diff Tool Task

Write a program that compares (at least) two text files.

  • The files to compare shall be specified on the command line.
  • The output should be per different line, on stdout.
  • You are encouraged to make changes to the provided skeleton.
  • You are expected to write additional tests to cover larger files and potential edge-cases.

Skeleton Contents

  • main.c with an example main() function;
  • include/ with some headers suggesting modules that you may want to implement in src/;
  • tests/ with sample input files & expected output, divided into solution stages;
  • run_tests.py so you don't spend more time in the terminal than in your editor.
  • Makefile to build the project.

Building & Testing

Linux:

  • cd bld && make; cd .. (or enter the commands separately)
  • ./run_tests.py 0 (where 0 is the stage you're testing)
    • If your build is broken: make clean from bld/

Windows:

  • cd bld; mingw32-make.exe; cd ..
  • python.exe run_tests.py 0 (where 0 is the stage you're testing)
    • If your build is broken: mingw32-make.exe clean from bld\

You may want to add extra compiler options in CFLAGS or specify extra source and include directories in the makefile.



Solution Stages

Not all diffs are created equal.

You are strongly encouraged to implement the program in increasing levels of functionality and sophistication.

The skeleton suggests the following stages:

Stage-0

Check files for strict equality. Meaning any difference is considered a negative, and no difference - a positive.

Suggested output:

"Files are identical." or "Files are different."

Stage-1

Count the number of non-identical lines. For each line, compare only its counterpart (so don't take added or deleted lines into account).

Suggested output:

"Files are identical.", "1 line differs.", or "15 lines differ."

Stage-2

Print the lines of each file that differ. If one file is longer than the other, also show the extra lines.

Suggested output:

Left 3: hello
Right 3: hi
Right 4: there

Stage-3

Your own design and tests. This is what will be evaluated.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published