Skip to content

arunksaha/ccwc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A toy version of wc

This is a toy version of the classic Unix tool wc.

NAME
       wc - print newline, word, and byte counts for each file

       wc [OPTION]... --files0-from=F

DESCRIPTION
       Print  newline,  word, and byte counts for each FILE, and a total line if more
       than one FILE is specified.  A word is a non-zero-length sequence of printable
       characters delimited by white space.

       With no FILE, or when FILE is -, read standard input.

       -c, --bytes
              print the byte counts

       -l, --lines
              print the newline counts

       -w, --words
              print the word counts

Build

$ make
Building ccwc...
go build -o bin/ccwc ./cmd/wc.go
Build complete. Binary available at bin/ccwc

Test

$ make test
Running all unit tests...
go test -v ./...
=== RUN   TestParseArgs
=== RUN   TestParseArgs/NoArgsDefaultsToStdin
=== RUN   TestParseArgs/ExplicitStdinFile
=== RUN   TestParseArgs/SingleFile
=== RUN   TestParseArgs/AllFlagsAndFile
=== RUN   TestParseArgs/MixedFlagsAndFile
=== RUN   TestParseArgs/OnlyBoolFlagsDefaultsToStdin
=== RUN   TestParseArgs/TooManyFiles
=== RUN   TestParseArgs/InvalidFlagError
--- PASS: TestParseArgs (0.00s)
    --- PASS: TestParseArgs/NoArgsDefaultsToStdin (0.00s)
    --- PASS: TestParseArgs/ExplicitStdinFile (0.00s)
    --- PASS: TestParseArgs/SingleFile (0.00s)
    --- PASS: TestParseArgs/AllFlagsAndFile (0.00s)
    --- PASS: TestParseArgs/MixedFlagsAndFile (0.00s)
    --- PASS: TestParseArgs/OnlyBoolFlagsDefaultsToStdin (0.00s)
    --- PASS: TestParseArgs/TooManyFiles (0.00s)
    --- PASS: TestParseArgs/InvalidFlagError (0.00s)
=== RUN   TestCountAll
=== RUN   TestCountAll/Empty_Input
=== RUN   TestCountAll/Single_Word
=== RUN   TestCountAll/Basic_Sentence
=== RUN   TestCountAll/Single_Line_Feed
=== RUN   TestCountAll/Multiple_Lines
=== RUN   TestCountAll/Leading_Trailing_Space
=== RUN   TestCountAll/Multiple_Spaces
=== RUN   TestCountAll/Tabs
=== RUN   TestCountAll/Mixed_Whitespace
=== RUN   TestCountAll/Only_Whitespace
=== RUN   TestCountAll/CRLF
=== RUN   TestCountAll/CRLF_Separate
=== RUN   TestCountAll/Simulated_Error
--- PASS: TestCountAll (0.00s)
    --- PASS: TestCountAll/Empty_Input (0.00s)
    --- PASS: TestCountAll/Single_Word (0.00s)
    --- PASS: TestCountAll/Basic_Sentence (0.00s)
    --- PASS: TestCountAll/Single_Line_Feed (0.00s)
    --- PASS: TestCountAll/Multiple_Lines (0.00s)
    --- PASS: TestCountAll/Leading_Trailing_Space (0.00s)
    --- PASS: TestCountAll/Multiple_Spaces (0.00s)
    --- PASS: TestCountAll/Tabs (0.00s)
    --- PASS: TestCountAll/Mixed_Whitespace (0.00s)
    --- PASS: TestCountAll/Only_Whitespace (0.00s)
    --- PASS: TestCountAll/CRLF (0.00s)
    --- PASS: TestCountAll/CRLF_Separate (0.00s)
    --- PASS: TestCountAll/Simulated_Error (0.00s)
=== RUN   TestWc
=== RUN   TestWc/Success
=== RUN   TestWc/File_Not_Found
--- PASS: TestWc (0.00s)
    --- PASS: TestWc/Success (0.00s)
    --- PASS: TestWc/File_Not_Found (0.00s)
=== RUN   TestWriteResult
--- PASS: TestWriteResult (0.00s)
PASS
ok  	github.com/arunksaha/ccwc	(cached)
?   	github.com/arunksaha/ccwc/cmd	[no test files]

Test coverage

$ make test-coverage
Generating test coverage profile...
go test -v ./... -coverprofile=coverage.out
=== RUN   TestParseArgs
<
< tuncated
<
PASS
coverage: 98.6% of statements
ok  	github.com/arunksaha/coding-challenges/wc	(cached)	coverage: 98.6% of statements

Test coverage pretty results in browser

$ make test-coverage-view
Opening coverage report in browser...
go tool cover -html=coverage.out -o coverage.html
Report saved to coverage.html. Please open this file in your browser to view the coverage.

Documentation

$ make doc

See http://localhost:6060/pkg/github.com/arunksaha/ccwc/

About

A toy version of wc

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published