12345678910111213141516171819202122232425262728 |
- package jsh
-
- import "testing"
-
- func TestNewProcess(t *testing.T) {
- tooManyArgs := []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}
- _, err := NewProcess(tooManyArgs)
- if err == nil {
- t.Errorf("Passing 12 strings should raise an error")
- }
-
- tooFewArgs := []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}
- _, err = NewProcess(tooFewArgs)
- if err == nil {
- t.Errorf("Passing 10 strings should raise an error")
- }
-
- justRightArgs := []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"}
- proc, err := NewProcess(justRightArgs)
- if err != nil {
- t.Errorf("Passing 11 strings should not raise an error")
- }
- expected := Process{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"}
- actual := *proc
- if expected != actual {
- t.Errorf("Proc was incorrectly generated:\n%s != %s", expected, actual)
- }
- }
|