Fixes for the new tested content.

master
Zed A. Shaw 2 months ago
parent 27b1f4ccf4
commit 1b307dc52d
  1. 12
      tested/cat/cat_test.go
  2. 8
      tested/cat/go.mod
  3. 10
      tested/cat/go.sum
  4. 2
      tested/cat/main.go
  5. 2
      tested/od/od_test.go
  6. 6
      tr/main.go
  7. 2
      uniq/main.go

@ -2,7 +2,6 @@ package main
import (
"testing"
"github.com/stretchr/testify/assert"
"os"
)
@ -14,11 +13,14 @@ func WithArgs(args []string, test func ()) {
}
func TestParseOpts(t *testing.T) {
args := []string{"cat.exe", "-n", "main.go"}
args := []string{"cat", "-n", "main.go"}
WithArgs(args, func () {
opts := ParseOpts()
assert.Equal(t, opts.Number, true, "-n didn't work")
if opts.Number != true {
t.Errorf("opts.Number should be true, not: %v", opts.Number)
}
})
/*
@ -26,7 +28,9 @@ func TestParseOpts(t *testing.T) {
args = []string{"cat.exe", "-s", "main.go"}
WithArgs(args, func () {
opts := ParseOpts()
assert.Equal(t, opts.Squeeze, true, "-s didn't work")
if opts.Number != true {
t.Errorf("opts.Number should be true, not: %v", opts.Number)
}
})
*/
}

@ -1,11 +1,3 @@
module lcthw.dev/go/go-coreutils/cat
go 1.24.2
require github.com/stretchr/testify v1.11.1
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

@ -1,10 +0,0 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

@ -17,8 +17,6 @@ type Opts struct {
func ParseOpts() (Opts) {
var opts Opts
fmt.Println("args:", os.Args)
flag.BoolVar(&opts.Number, "n", false, "Number all nonempty output lines, starting with 1")
flag.BoolVar(&opts.Squeeze, "s", false, "Suppress repeated adjacent blank lines")
flag.Parse()

@ -10,7 +10,7 @@ func TestParseOpts(t *testing.T) {
opts := ParseOpts(args)
assert.Equal(t, opts.Hex, true, "-x didn't work")
// This fails because flag can't be run more than once
// now we can test as much as we want
args = []string{"cat.exe", "-o", "main.go"}
opts = ParseOpts(args)
assert.Equal(t, opts.Octal, true, "-o didn't work")

@ -1,12 +1,12 @@
package main
import (
"flag"
"os"
"bufio"
"strings"
"flag"
"fmt"
"log"
"os"
"strings"
)
type Opts struct {

@ -17,7 +17,7 @@ func ParseOpts() Opts {
var opts Opts
flag.BoolVar(&opts.IgnoreCase, "i", false, "ignore case")
flag.BoolVar(&opts.Count, "c", false, "count occurence")
flag.BoolVar(&opts.Count, "c", false, "count occurrence")
flag.Parse()
return opts

Loading…
Cancel
Save