How to use areEqual method of is Package

Best Is code snippet using is.areEqual

simhandler_test.go

Source:simhandler_test.go Github

copy

Full Screen

1package srvr2import (3 "bufio"4 "encoding/json"5 "fmt"6 "net/http"7 "strconv"8 "strings"9 "testing"10 "github.com/codeafix/orgnetsim/sim"11 "github.com/google/uuid"12 "github.com/spaceweasel/mango"13)14func CreateNetwork() sim.RelationshipMgr {15 rm := &sim.Network{}16 agent1 := sim.GenerateRandomAgent("Agent_1", []sim.Color{sim.Blue}, false)17 rm.AddAgent(agent1)18 agent2 := sim.GenerateRandomAgent("Agent_2", []sim.Color{sim.Blue}, false)19 rm.AddAgent(agent2)20 agent3 := sim.GenerateRandomAgent("Agent_3", []sim.Color{sim.Blue}, false)21 rm.AddAgent(agent3)22 rm.AddLink(agent1, agent2)23 rm.AddLink(agent1, agent3)24 rm.SetMaxColors(4)25 rm.PopulateMaps()26 return rm27}28func CreateSimHandlerBrowserWithSteps(deleteItemIndex int) (*mango.Browser, *TestFileUpdater, *TestFileUpdater, *TestFileUpdater, []string, string) {29 simid := uuid.New().String()30 sim := NewSimInfo(simid)31 sim.Name = "mySavedSim"32 sim.Description = "A description of mySavedSim"33 ids := []string{34 uuid.NewString(),35 uuid.NewString(),36 uuid.NewString(),37 }38 steps := make([]string, len(ids))39 for i, id := range ids {40 steps[i] = fmt.Sprintf("/api/simulation/%s/step/%s", simid, id)41 }42 sim.Steps = steps43 simfu := &TestFileUpdater{44 Obj: sim,45 Filepath: sim.Filepath(),46 }47 tfm := NewTestFileManager(simfu)48 ss := &SimStep{49 ID: ids[deleteItemIndex],50 ParentID: simid,51 Network: CreateNetwork(),52 }53 ssfu := &TestFileUpdater{54 Obj: ss,55 Filepath: ss.Filepath(),56 }57 tfm.Add(ss.Filepath(), ssfu)58 dfu := &TestFileUpdater{}59 tfm.Default = dfu60 r := CreateRouter(tfm)61 br := mango.NewBrowser(r)62 return br, simfu, ssfu, dfu, steps, simid63}64func TestMarshalling(t *testing.T) {65 parent := uuid.NewString()66 s1 := &SimStep{67 ID: uuid.NewString(),68 ParentID: parent,69 Network: CreateNetwork(),70 }71 s2 := &SimStep{72 ID: uuid.NewString(),73 ParentID: parent,74 Network: CreateNetwork(),75 }76 steps := []*SimStep{s1, s2}77 b, err := json.Marshal(steps)78 AssertSuccess(t, err)79 rstep := []*SimStep{}80 err = json.Unmarshal(b, &rstep)81 AssertSuccess(t, err)82}83func TestGetSimSuccess(t *testing.T) {84 br, simfu, _, _, _, simid := CreateSimHandlerBrowserWithSteps(0)85 hdrs := http.Header{}86 resp, err := br.Get(fmt.Sprintf("/api/simulation/%s", simid), hdrs)87 AssertSuccess(t, err)88 AreEqual(t, http.StatusOK, resp.Code, "Not OK")89 rsim := &SimInfo{}90 err = json.Unmarshal(resp.Body.Bytes(), rsim)91 AssertSuccess(t, err)92 AreEqual(t, simfu.Obj.(*SimInfo).Name, rsim.Name, "Wrong name in returned SimInfo")93 AreEqual(t, simfu.Obj.(*SimInfo).Description, rsim.Description, "Wrong description in returned SimInfo")94}95func TestGetSimInvalidCommand(t *testing.T) {96 br, _, _, _, _, simid := CreateSimHandlerBrowserWithSteps(0)97 hdrs := http.Header{}98 resp, err := br.Get(fmt.Sprintf("/api/simulation/%s/somename", simid), hdrs)99 AssertSuccess(t, err)100 AreEqual(t, http.StatusNotFound, resp.Code, "Did not return Not Found")101}102func TestGetSimStepsSuccess(t *testing.T) {103 br, _, _, _, steps, simid := CreateSimHandlerBrowserWithSteps(0)104 hdrs := http.Header{}105 resp, err := br.Get(fmt.Sprintf("/api/simulation/%s/step", simid), hdrs)106 AssertSuccess(t, err)107 AreEqual(t, http.StatusOK, resp.Code, "Not OK")108 rsteps := []SimStep{}109 err = json.Unmarshal(resp.Body.Bytes(), &rsteps)110 AssertSuccess(t, err)111 AreEqual(t, 3, len(rsteps), "Wrong number of Steps in returned SimInfo")112 AreEqual(t, steps[0][strings.LastIndex(steps[0], "/")+1:], rsteps[0].ID, "Wrong Step 0 in returned SimInfo")113 AreEqual(t, steps[1][strings.LastIndex(steps[0], "/")+1:], rsteps[1].ID, "Wrong Step 1 in returned SimInfo")114 AreEqual(t, steps[2][strings.LastIndex(steps[0], "/")+1:], rsteps[2].ID, "Wrong Step 2 in returned SimInfo")115}116func TestUpdateSimSuccess(t *testing.T) {117 br, _, _, _, steps, simid := CreateSimHandlerBrowserWithSteps(0)118 hdrs := http.Header{}119 hdrs.Set("Content-Type", "application/json")120 data := `{"Name":"myUpdatedSim","Description":"A description of mySavedSim"}`121 resp, err := br.PutS(fmt.Sprintf("/api/simulation/%s", simid), data, hdrs)122 AssertSuccess(t, err)123 AreEqual(t, http.StatusOK, resp.Code, "Not OK")124 rsim := &SimInfo{}125 err = json.Unmarshal(resp.Body.Bytes(), rsim)126 AssertSuccess(t, err)127 AreEqual(t, "myUpdatedSim", rsim.Name, "Wrong name in returned SimInfo")128 AreEqual(t, "A description of mySavedSim", rsim.Description, "Wrong description in returned SimInfo")129 AreEqual(t, 3, len(rsim.Steps), "Wrong number of Steps in returned SimInfo")130 AreEqual(t, steps[0], rsim.Steps[0], "Wrong Step 0 in returned SimInfo")131 AreEqual(t, steps[1], rsim.Steps[1], "Wrong Step 1 in returned SimInfo")132 AreEqual(t, steps[2], rsim.Steps[2], "Wrong Step 2 in returned SimInfo")133}134func TestDeleteSimSuccess(t *testing.T) {135 br, simfu, ssfu, _, steps, _ := CreateSimHandlerBrowserWithSteps(0)136 hdrs := http.Header{}137 hdrs.Set("Content-Type", "application/json")138 resp, err := br.Delete(steps[0], hdrs)139 AssertSuccess(t, err)140 AreEqual(t, http.StatusOK, resp.Code, "Not OK")141 AreEqual(t, 2, len(simfu.Obj.(*SimInfo).Steps), "There should be two items in the list")142 AreEqual(t, steps[1], simfu.Obj.(*SimInfo).Steps[0], "Wrong path in position 0 of step list")143 AreEqual(t, steps[2], simfu.Obj.(*SimInfo).Steps[1], "Wrong path in position 1 of step list")144 IsTrue(t, ssfu.DeleteCalled, "Delete was not called on the correct fileupdater")145}146func TestGenerateNetworkFailsIfStepsExist(t *testing.T) {147 br, _, _, _, _, simid := CreateSimHandlerBrowserWithSteps(0)148 hs := sim.HierarchySpec{149 Levels: 2,150 TeamSize: 2,151 InitColors: []sim.Color{sim.Blue},152 MaxColors: 4,153 }154 hss, err := json.Marshal(hs)155 AssertSuccess(t, err)156 hdrs := http.Header{}157 hdrs.Set("Content-Type", "application/json")158 resp, err := br.PostS(fmt.Sprintf("/api/simulation/%s/generate", simid), string(hss), hdrs)159 AssertSuccess(t, err)160 AreEqual(t, http.StatusBadRequest, resp.Code, "Not Bad Request")161 AreEqual(t, "Simulation must have no steps when generating a new network", strings.TrimSpace(resp.Body.String()), "Incorrect error response")162}163func TestParseNetworkFailsIfStepsExist(t *testing.T) {164 br, _, _, _, _, simid := CreateSimHandlerBrowserWithSteps(0)165 data := []string{166 "Header row is always skipped ,check_this_is_not_an_Id,,\n",167 "Should be ignored|||\n",168 "\n",169 "Strips ws around Id, my_id\n",170 "Blank lines are ignored\n",171 }172 var payload = []byte{}173 for _, s := range data {174 payload = append(payload, []byte(s)...)175 }176 pb := ParseBody{177 ParseOptions: sim.ParseOptions{178 Delimiter: ",",179 Identifier: 1,180 Parent: 3,181 },182 Payload: payload,183 }184 pbs, err := json.Marshal(pb)185 AssertSuccess(t, err)186 hdrs := http.Header{}187 hdrs.Set("Content-Type", "application/json")188 resp, err := br.PostS(fmt.Sprintf("/api/simulation/%s/parse", simid), string(pbs), hdrs)189 AssertSuccess(t, err)190 AreEqual(t, http.StatusBadRequest, resp.Code, "Not Bad Request")191 AreEqual(t, "Simulation must have no steps when parsing a new network", strings.TrimSpace(resp.Body.String()), "Incorrect error response")192}193func CreateSimHandlerBrowser() (*mango.Browser, *TestFileUpdater, *TestFileUpdater, string) {194 simid := uuid.New().String()195 nsim := NewSimInfo(simid)196 nsim.Name = "mySavedSim"197 nsim.Description = "A description of mySavedSim"198 nsim.Steps = []string{}199 nsim.Options.LinkedTeamList = []string{}200 nsim.Options.EvangelistList = []string{}201 nsim.Options.LoneEvangelist = []string{}202 nsim.Options.InitColors = []sim.Color{}203 simfu := &TestFileUpdater{204 Obj: nsim,205 Filepath: nsim.Filepath(),206 }207 tfm := NewTestFileManager(simfu)208 ssfu := &TestFileUpdater{}209 tfm.SetDefault(ssfu)210 r := CreateRouter(tfm)211 br := mango.NewBrowser(r)212 return br, simfu, ssfu, simid213}214func TestParseNetworkSucceeds(t *testing.T) {215 br, simfu, ssfu, simid := CreateSimHandlerBrowser()216 savedsim, ok := simfu.Obj.(*SimInfo)217 IsTrue(t, ok, "Saved object would not cast to *SimInfo")218 savedsim.Options.MaxColors = 5219 data := []string{220 "Header always skipped ,check_this_is_not_an_Id\n",221 "Should be ignored|||\n",222 "\n",223 "Strips ws around Id, my_id\n",224 "Blank lines are ignored\n",225 "First agent, agent_1, some text,,\n",226 "Second agent, agent_2, more text, agent_1,\n",227 }228 var payload = []byte{}229 for _, s := range data {230 payload = append(payload, []byte(s)...)231 }232 pb := ParseBody{233 ParseOptions: sim.ParseOptions{234 Delimiter: ",",235 Identifier: 1,236 Parent: 3,237 },238 Payload: payload,239 }240 pbs, err := json.Marshal(pb)241 AssertSuccess(t, err)242 hdrs := http.Header{}243 hdrs.Set("Content-Type", "application/json")244 resp, err := br.PostS(fmt.Sprintf("/api/simulation/%s/parse", simid), string(pbs), hdrs)245 AssertSuccess(t, err)246 AreEqual(t, http.StatusCreated, resp.Code, "Not Created")247 simstep, ok := ssfu.Obj.(*SimStep)248 IsTrue(t, ok, "Saved object would not cast to *SimStep")249 AreEqual(t, 5, simstep.Network.MaxColors(), "Wrong MaxColors on network")250 IsTrue(t, simstep.Network.Links() != nil, "Links array is nil")251 AreEqual(t, len(simstep.Network.Links()), 1, "Links should have a single item")252 IsTrue(t, simstep.Network.Agents() != nil, "Agents array is nil")253 AreEqual(t, len(simstep.Network.Agents()), 3, "Agents array should have 3 items")254}255func TestGenerateNetworkSucceeds(t *testing.T) {256 br, simfu, ssfu, simid := CreateSimHandlerBrowser()257 hs := sim.HierarchySpec{258 Levels: 2,259 TeamSize: 2,260 InitColors: []sim.Color{sim.Green},261 MaxColors: 4,262 }263 hss, err := json.Marshal(hs)264 AssertSuccess(t, err)265 hdrs := http.Header{}266 hdrs.Set("Content-Type", "application/json")267 resp, err := br.PostS(fmt.Sprintf("/api/simulation/%s/generate", simid), string(hss), hdrs)268 AssertSuccess(t, err)269 AreEqual(t, http.StatusCreated, resp.Code, "Not Created")270 simstep, ok := ssfu.Obj.(*SimStep)271 IsTrue(t, ok, "Saved object would not cast to *SimStep")272 AreEqual(t, 4, simstep.Network.MaxColors(), "Wrong MaxColors on network")273 AreEqual(t, 3, len(simstep.Network.Agents()), "Wrong number of agents on network")274 AreEqual(t, 4, len(simstep.Results.Colors[0]), "Wrong number of Colors in Color results array")275 AreEqual(t, 3, simstep.Results.Colors[0][3], "Wrong Green Color count in results array")276 sim, ok := simfu.Obj.(*SimInfo)277 IsTrue(t, ok, "Saved object would not cast to *SimInfo")278 AreEqual(t, 1, len(sim.Options.InitColors), "Wrong InitColors on sim options")279 AreEqual(t, hs.InitColors[0], sim.Options.InitColors[0], "Wrong InitColors on sim options")280 AreEqual(t, hs.MaxColors, sim.Options.MaxColors, "Wrong MaxColors on sim options")281}282func TestPostRunFailsIfNoStepsExist(t *testing.T) {283 br, _, _, simid := CreateSimHandlerBrowser()284 rs := RunSpec{285 Iterations: 5,286 Steps: 5,287 }288 rss, err := json.Marshal(rs)289 AssertSuccess(t, err)290 hdrs := http.Header{}291 hdrs.Set("Content-Type", "application/json")292 resp, err := br.PostS(fmt.Sprintf("/api/simulation/%s/run", simid), string(rss), hdrs)293 AssertSuccess(t, err)294 AreEqual(t, http.StatusBadRequest, resp.Code, "Not Bad request")295 AreEqual(t, "The simulation cannot be run without an initial step containing a network", strings.TrimSpace(resp.Body.String()), "Incorrect error response")296}297func TestPostRunFailsWithZeroIterations(t *testing.T) {298 br, _, _, _, _, simid := CreateSimHandlerBrowserWithSteps(2)299 rs := RunSpec{300 Iterations: 0,301 Steps: 5,302 }303 rss, err := json.Marshal(rs)304 AssertSuccess(t, err)305 hdrs := http.Header{}306 hdrs.Set("Content-Type", "application/json")307 resp, err := br.PostS(fmt.Sprintf("/api/simulation/%s/run", simid), string(rss), hdrs)308 AssertSuccess(t, err)309 AreEqual(t, http.StatusBadRequest, resp.Code, "Not Bad request")310 AreEqual(t, "Steps and Iterations cannot be zero", strings.TrimSpace(resp.Body.String()), "Incorrect error response")311}312func TestPostRunFailsWithZeroStepCount(t *testing.T) {313 br, _, _, _, _, simid := CreateSimHandlerBrowserWithSteps(2)314 rs := RunSpec{315 Iterations: 0,316 Steps: 5,317 }318 rss, err := json.Marshal(rs)319 AssertSuccess(t, err)320 hdrs := http.Header{}321 hdrs.Set("Content-Type", "application/json")322 resp, err := br.PostS(fmt.Sprintf("/api/simulation/%s/run", simid), string(rss), hdrs)323 AssertSuccess(t, err)324 AreEqual(t, http.StatusBadRequest, resp.Code, "Not Bad request")325 AreEqual(t, "Steps and Iterations cannot be zero", strings.TrimSpace(resp.Body.String()), "Incorrect error response")326}327func TestPostRunSucceedsWithOneStep(t *testing.T) {328 br, _, _, dfu, _, simid := CreateSimHandlerBrowserWithSteps(2)329 rs := RunSpec{330 Iterations: 5,331 Steps: 1,332 }333 rss, err := json.Marshal(rs)334 AssertSuccess(t, err)335 hdrs := http.Header{}336 hdrs.Set("Content-Type", "application/json")337 resp, err := br.PostS(fmt.Sprintf("/api/simulation/%s/run", simid), string(rss), hdrs)338 AssertSuccess(t, err)339 AreEqual(t, http.StatusCreated, resp.Code, "Not created")340 ns := dfu.Obj.(*SimStep)341 NotEqual(t, nil, ns, "New step is nil")342 AreEqual(t, 4, ns.Network.MaxColors(), "MaxColors not correct on new network")343 //Check there are 5 items in the results arrays, one for each iteration344 AreEqual(t, 5, len(ns.Results.Colors), "Wrong number of items in the Colors array")345 AreEqual(t, 5, len(ns.Results.Conversations), "Wrong number of items in the Conversations array")346}347func CreateResults(iterations, maxColors int) sim.Results {348 results := sim.Results{349 Iterations: iterations,350 Colors: make([][]int, iterations),351 Conversations: make([]int, iterations),352 }353 for i := 0; i < iterations; i++ {354 results.Conversations[i] = i + 1355 colorCounts := make([]int, maxColors)356 for j := 0; j < maxColors; j++ {357 colorCounts[j] = i + j358 }359 results.Colors[i] = colorCounts360 }361 return results362}363func CreateSimHandlerBrowserWithStepsAndResults() (*mango.Browser, string) {364 simid := uuid.New().String()365 sim := NewSimInfo(simid)366 sim.Name = "mySavedSim"367 sim.Description = "A description of mySavedSim"368 ids := []string{369 uuid.New().String(),370 uuid.New().String(),371 uuid.New().String(),372 }373 simfu := &TestFileUpdater{374 Obj: sim,375 Filepath: sim.Filepath(),376 }377 tfm := NewTestFileManager(simfu)378 steps := make([]string, len(ids))379 for i, id := range ids {380 steps[i] = fmt.Sprintf("/api/simulation/%s/step/%s", simid, id)381 ss := &SimStep{382 ID: id,383 ParentID: simid,384 Results: CreateResults(i+1, 4),385 }386 ssfu := &TestFileUpdater{387 Obj: ss,388 Filepath: ss.Filepath(),389 }390 tfm.Add(ss.Filepath(), ssfu)391 }392 sim.Steps = steps393 r := CreateRouter(tfm)394 br := mango.NewBrowser(r)395 return br, simid396}397func TestGetResultsSucceeds(t *testing.T) {398 br, simid := CreateSimHandlerBrowserWithStepsAndResults()399 hdrs := http.Header{}400 resp, err := br.Get(fmt.Sprintf("/api/simulation/%s/results", simid), hdrs)401 AssertSuccess(t, err)402 AreEqual(t, http.StatusOK, resp.Code, "Not OK")403 rs := &sim.Results{}404 json.Unmarshal(resp.Body.Bytes(), rs)405 AreEqual(t, 6, rs.Iterations, "Wrong number of iterations")406 AreEqual(t, 1, rs.Conversations[0], "Wrong conversation count")407 AreEqual(t, 1, rs.Conversations[1], "Wrong conversation count")408 AreEqual(t, 2, rs.Conversations[2], "Wrong conversation count")409 AreEqual(t, 1, rs.Conversations[3], "Wrong conversation count")410 AreEqual(t, 2, rs.Conversations[4], "Wrong conversation count")411 AreEqual(t, 3, rs.Conversations[5], "Wrong conversation count")412 AreEqual(t, 3, rs.Colors[0][3], "Wrong color count")413 AreEqual(t, 3, rs.Colors[1][3], "Wrong color count")414 AreEqual(t, 4, rs.Colors[2][3], "Wrong color count")415 AreEqual(t, 3, rs.Colors[3][3], "Wrong color count")416 AreEqual(t, 4, rs.Colors[4][3], "Wrong color count")417 AreEqual(t, 5, rs.Colors[5][3], "Wrong color count")418}419func TestGetResultsSucceedsAsCsv(t *testing.T) {420 br, simid := CreateSimHandlerBrowserWithStepsAndResults()421 hdrs := http.Header{422 "Content-Type": []string{"text/csv"},423 }424 resp, err := br.Get(fmt.Sprintf("/api/simulation/%s/results", simid), hdrs)425 AssertSuccess(t, err)426 AreEqual(t, http.StatusOK, resp.Code, "Not OK")427 csv := resp.Body.String()428 scanner := bufio.NewScanner(strings.NewReader(csv))429 //check the headers are correct430 ct := false431 for _, header := range resp.Header()[http.CanonicalHeaderKey("content-type")] {432 if header == "text/csv" {433 ct = true434 break435 }436 }437 IsTrue(t, ct, "content-type header incorrect or missing")438 IsTrue(t, len(resp.Header()[http.CanonicalHeaderKey("content-disposition")]) > 0, "content-disposition missing")439 //Read the header line440 scanner.Scan()441 endCol := len(strings.Split(scanner.Text(), ",")) - 1442 //convert the csv into an array of int arrays443 rs := [][]int{}444 i := 0445 for scanner.Scan() {446 strs := strings.Split(scanner.Text(), ",")447 vals := make([]int, endCol+1)448 for j, val := range strs {449 vals[j], _ = strconv.Atoi(val)450 }451 rs = append(rs, vals)452 i++453 }454 //Check the results are correct455 AreEqual(t, 6, len(rs), "Wrong number of iterations")456 AreEqual(t, 1, rs[0][endCol], "Wrong conversation count")457 AreEqual(t, 1, rs[1][endCol], "Wrong conversation count")458 AreEqual(t, 2, rs[2][endCol], "Wrong conversation count")459 AreEqual(t, 1, rs[3][endCol], "Wrong conversation count")460 AreEqual(t, 2, rs[4][endCol], "Wrong conversation count")461 AreEqual(t, 3, rs[5][endCol], "Wrong conversation count")462 AreEqual(t, 3, rs[0][3], "Wrong color count")463 AreEqual(t, 3, rs[1][3], "Wrong color count")464 AreEqual(t, 4, rs[2][3], "Wrong color count")465 AreEqual(t, 3, rs[3][3], "Wrong color count")466 AreEqual(t, 4, rs[4][3], "Wrong color count")467 AreEqual(t, 5, rs[5][3], "Wrong color count")468}...

Full Screen

Full Screen

simlisthandler_test.go

Source:simlisthandler_test.go Github

copy

Full Screen

1package srvr2import (3 "encoding/json"4 "fmt"5 "net/http"6 "testing"7 "github.com/google/uuid"8 "github.com/spaceweasel/mango"9)10func CreateSimListHandlerBrowser() (*mango.Browser, *TestFileUpdater, *TestFileUpdater, *TestFileManager) {11 sl := NewSimList()12 sl.Items = []string{13 "/api/simulation/{someIdHere}",14 }15 sl.Notes = "Some notes"16 slfu := &TestFileUpdater{17 Obj: sl,18 Filepath: sl.Filepath(),19 }20 tfm := NewTestFileManager(slfu)21 dfu := &TestFileUpdater{}22 tfm.SetDefault(dfu)23 r := CreateRouter(tfm)24 br := mango.NewBrowser(r)25 return br, slfu, dfu, tfm26}27func TestUpdateSimListNotesSuccess(t *testing.T) {28 br, slfu, _, _ := CreateSimListHandlerBrowser()29 hdrs := http.Header{}30 hdrs.Set("Content-Type", "application/json")31 data := `{"Notes":"some different notes"}`32 resp, err := br.PutS("/api/simulation/notes", data, hdrs)33 AssertSuccess(t, err)34 AreEqual(t, http.StatusOK, resp.Code, "Not OK")35 AreEqual(t, 1, len(slfu.Obj.(*SimList).Items), "There should still be one item in the list")36 AreEqual(t, "/api/simulation/{someIdHere}", slfu.Obj.(*SimList).Items[0], "Sim list changed when updating notes")37 rsl := &SimList{}38 err = json.Unmarshal(resp.Body.Bytes(), rsl)39 AssertSuccess(t, err)40 AreEqual(t, 1, len(rsl.Items), "There should be one item in the returned list")41 AreEqual(t, "/api/simulation/{someIdHere}", rsl.Items[0], "Returned Sim list changed when updating notes")42 AreEqual(t, "some different notes", rsl.Notes, "Returned notes not updated")43}44func TestGetSimList(t *testing.T) {45 br, _, _, _ := CreateSimListHandlerBrowser()46 hdrs := http.Header{}47 resp, err := br.Get("/api/simulation", hdrs)48 AssertSuccess(t, err)49 AreEqual(t, http.StatusOK, resp.Code, "Not OK")50 rsl := &SimListExt{51 TimestampHolder: TimestampHolder{},52 Items: []*SimInfo{},53 Notes: "",54 }55 json.Unmarshal(resp.Body.Bytes(), rsl)56 AreEqual(t, 1, len(rsl.Items), "Wrong number of items in returned list")57 AreEqual(t, "{someIdHere}", rsl.Items[0].ID, "Wrong item in list")58 AreEqual(t, "Some notes", rsl.Notes, "Wrong notes")59}60func TestGetSimListReturnErrorWhenReadFails(t *testing.T) {61 br, slfu, _, _ := CreateSimListHandlerBrowser()62 slfu.ReadErr = fmt.Errorf("Access denied")63 hdrs := http.Header{}64 resp, err := br.Get("/api/simulation", hdrs)65 AssertSuccess(t, err)66 AreEqual(t, http.StatusInternalServerError, resp.Code, "Not Error")67 AreEqual(t, "Access denied", resp.Body.String(), "Incorrect error message")68}69func TestAddSimToSimListSuccess(t *testing.T) {70 br, slfu, dfu, _ := CreateSimListHandlerBrowser()71 hdrs := http.Header{}72 hdrs.Set("Content-Type", "application/json")73 data := `{"Name":"mySim","Description":"A description of my sim"}`74 resp, err := br.PostS("/api/simulation", data, hdrs)75 AssertSuccess(t, err)76 AreEqual(t, http.StatusCreated, resp.Code, "Not OK")77 AreEqual(t, 2, len(slfu.Obj.(*SimList).Items), "There should be two items in the list")78 AreEqual(t, fmt.Sprintf("/api/simulation/%s", dfu.Obj.(*SimInfo).ID), slfu.Obj.(*SimList).Items[1], "Wrong path added to sim list")79 rsim := &SimInfo{}80 err = json.Unmarshal(resp.Body.Bytes(), rsim)81 AssertSuccess(t, err)82 AreEqual(t, dfu.Obj.(*SimInfo).ID, rsim.ID, "ID of returned SimInfo incorrect")83 AreEqual(t, "mySim", rsim.Name, "Name of returned SimInfo incorrect")84 AreEqual(t, "A description of my sim", rsim.Description, "Description of returned SimInfo incorrect")85}86func TestAddsSimToEmptySimListSuccess(t *testing.T) {87 br, slfu, dfu, _ := CreateSimListHandlerBrowser()88 slfu.Obj = NewSimList()89 hdrs := http.Header{}90 hdrs.Set("Content-Type", "application/json")91 data := `{"Name":"mySim","Description":"A description of my sim"}`92 resp, err := br.PostS("/api/simulation", data, hdrs)93 AssertSuccess(t, err)94 AreEqual(t, http.StatusCreated, resp.Code, "Not OK")95 AreEqual(t, 1, len(slfu.Obj.(*SimList).Items), "There should be one item in the list")96 AreEqual(t, fmt.Sprintf("/api/simulation/%s", dfu.Obj.(*SimInfo).ID), slfu.Obj.(*SimList).Items[0], "Wrong path added to sim list")97 rsim := &SimInfo{}98 err = json.Unmarshal(resp.Body.Bytes(), rsim)99 AssertSuccess(t, err)100 AreEqual(t, dfu.Obj.(*SimInfo).ID, rsim.ID, "ID of returned SimInfo incorrect")101 AreEqual(t, "mySim", rsim.Name, "Name of returned SimInfo incorrect")102 AreEqual(t, "A description of my sim", rsim.Description, "Description of returned SimInfo incorrect")103}104func TestAddSimListFailsWithWrongHeaders(t *testing.T) {105 br, _, _, _ := CreateSimListHandlerBrowser()106 hdrs := http.Header{}107 data := `{"Name":"mySim","Description":"A description of my sim"}`108 resp, err := br.PostS("/api/simulation", data, hdrs)109 AssertSuccess(t, err)110 AreEqual(t, http.StatusBadRequest, resp.Code, "Not Bad request")111}112func TestAddSimListReturnsErrorWithFileReadErr(t *testing.T) {113 br, slfu, _, _ := CreateSimListHandlerBrowser()114 slfu.ReadErr = fmt.Errorf("Access denied")115 hdrs := http.Header{}116 hdrs.Set("Content-Type", "application/json")117 data := `{"Name":"mySim","Description":"A description of my sim"}`118 resp, err := br.PostS("/api/simulation", data, hdrs)119 AssertSuccess(t, err)120 AreEqual(t, http.StatusInternalServerError, resp.Code, "No error reported")121 Contains(t, "Access denied", resp.Body.String(), "Wrong error reported")122}123func TestAddSimListReturnsErrorWithFileUpdateErr(t *testing.T) {124 br, slfu, _, _ := CreateSimListHandlerBrowser()125 slfu.UpdateErr = fmt.Errorf("Access denied")126 hdrs := http.Header{}127 hdrs.Set("Content-Type", "application/json")128 data := `{"Name":"mySim","Description":"A description of my sim"}`129 resp, err := br.PostS("/api/simulation", data, hdrs)130 AssertSuccess(t, err)131 AreEqual(t, http.StatusInternalServerError, resp.Code, "No error reported")132 Contains(t, "Access denied", resp.Body.String(), "Wrong error reported")133}134func TestAddSimListReturnsErrorWithFileCreateErr(t *testing.T) {135 br, _, dfu, _ := CreateSimListHandlerBrowser()136 dfu.CreateErr = fmt.Errorf("Access denied")137 hdrs := http.Header{}138 hdrs.Set("Content-Type", "application/json")139 data := `{"Name":"mySim","Description":"A description of my sim"}`140 resp, err := br.PostS("/api/simulation", data, hdrs)141 AssertSuccess(t, err)142 AreEqual(t, http.StatusInternalServerError, resp.Code, "No error reported")143 Contains(t, "Access denied", resp.Body.String(), "Wrong error reported")144}145func SetupForDeleteTests(deleteItemIndex int) (*mango.Browser, *TestFileUpdater, *TestFileUpdater, []string) {146 br, slfu, _, tfm := CreateSimListHandlerBrowser()147 sl := NewSimList()148 ids := []string{149 uuid.New().String(),150 uuid.New().String(),151 uuid.New().String(),152 }153 items := make([]string, len(ids))154 for i, id := range ids {155 items[i] = fmt.Sprintf("/api/simulation/%s", id)156 }157 sl.Items = items158 slfu.Obj = sl159 sim := &SimInfo{160 ID: ids[deleteItemIndex],161 }162 simfu := &TestFileUpdater{163 Obj: sim,164 Filepath: sim.Filepath(),165 }166 tfm.Add(sim.Filepath(), simfu)167 return br, slfu, simfu, items168}169func TestDeleteFirstSimFromSimListSuccess(t *testing.T) {170 br, slfu, simfu, items := SetupForDeleteTests(0)171 hdrs := http.Header{}172 resp, err := br.Delete(items[0], hdrs)173 AssertSuccess(t, err)174 AreEqual(t, http.StatusOK, resp.Code, "Not OK")175 AreEqual(t, 2, len(slfu.Obj.(*SimList).Items), "There should be two items in the list")176 AreEqual(t, items[1], slfu.Obj.(*SimList).Items[0], "Wrong path in position 0 of sim list")177 AreEqual(t, items[2], slfu.Obj.(*SimList).Items[1], "Wrong path in position 1 of sim list")178 IsTrue(t, simfu.DeleteCalled, "Delete was not called on the correct fileupdater")179}180func TestDeleteMiddleSimFromSimListSuccess(t *testing.T) {181 br, slfu, simfu, items := SetupForDeleteTests(1)182 hdrs := http.Header{}183 resp, err := br.Delete(items[1], hdrs)184 AssertSuccess(t, err)185 AreEqual(t, http.StatusOK, resp.Code, "Not OK")186 AreEqual(t, 2, len(slfu.Obj.(*SimList).Items), "There should be two items in the list")187 AreEqual(t, items[0], slfu.Obj.(*SimList).Items[0], "Wrong path in position 0 of sim list")188 AreEqual(t, items[2], slfu.Obj.(*SimList).Items[1], "Wrong path in position 1 of sim list")189 IsTrue(t, simfu.DeleteCalled, "Delete was not called on the correct fileupdater")190}191func TestDeleteLastSimFromSimListSuccess(t *testing.T) {192 br, slfu, simfu, items := SetupForDeleteTests(2)193 hdrs := http.Header{}194 resp, err := br.Delete(items[2], hdrs)195 AssertSuccess(t, err)196 AreEqual(t, http.StatusOK, resp.Code, "Not OK")197 AreEqual(t, 2, len(slfu.Obj.(*SimList).Items), "There should be two items in the list")198 AreEqual(t, items[0], slfu.Obj.(*SimList).Items[0], "Wrong path in position 0 of sim list")199 AreEqual(t, items[1], slfu.Obj.(*SimList).Items[1], "Wrong path in position 1 of sim list")200 IsTrue(t, simfu.DeleteCalled, "Delete was not called on the correct fileupdater")201}202func TestDeleteSimFromSimListReturnsNotFoundWhenListEmpty(t *testing.T) {203 br, slfu, _, _ := CreateSimListHandlerBrowser()204 sl := NewSimList()205 slfu.Obj = sl206 hdrs := http.Header{}207 resp, err := br.Delete(fmt.Sprintf("/api/simulation/%s", uuid.New().String()), hdrs)208 AssertSuccess(t, err)209 AreEqual(t, http.StatusNotFound, resp.Code, "Not Found not reported")210}211func TestDeleteSimFromSimListReturnsNotFoundWhenNotInList(t *testing.T) {212 br, _, _, _ := SetupForDeleteTests(0)213 hdrs := http.Header{}214 resp, err := br.Delete(fmt.Sprintf("/api/simulation/%s", uuid.New().String()), hdrs)215 AssertSuccess(t, err)216 AreEqual(t, http.StatusNotFound, resp.Code, "Not Found not reported")217}218func TestDeleteReturnsErrorWhenSimListReadErr(t *testing.T) {219 br, slfu, simfu, items := SetupForDeleteTests(0)220 slfu.ReadErr = fmt.Errorf("Access denied")221 hdrs := http.Header{}222 resp, err := br.Delete(items[0], hdrs)223 AssertSuccess(t, err)224 AreEqual(t, http.StatusInternalServerError, resp.Code, "Not error")225 Contains(t, "Access denied", resp.Body.String(), "Wrong error reported")226 IsFalse(t, simfu.DeleteCalled, "Delete was still called on the Sim fileupdater")227}228func TestDeleteReturnsErrorWhenSimListUpdateErr(t *testing.T) {229 br, slfu, simfu, items := SetupForDeleteTests(0)230 slfu.UpdateErr = fmt.Errorf("Access denied")231 hdrs := http.Header{}232 resp, err := br.Delete(items[0], hdrs)233 AssertSuccess(t, err)234 AreEqual(t, http.StatusInternalServerError, resp.Code, "Not error")235 Contains(t, "Access denied", resp.Body.String(), "Wrong error reported")236 IsFalse(t, simfu.DeleteCalled, "Delete was still called on the Sim fileupdater")237}238func TestDeleteReturnsErrorWhenSimDeleteErr(t *testing.T) {239 br, _, simfu, items := SetupForDeleteTests(0)240 simfu.DeleteErr = fmt.Errorf("Access denied")241 hdrs := http.Header{}242 resp, err := br.Delete(items[0], hdrs)243 AssertSuccess(t, err)244 AreEqual(t, http.StatusInternalServerError, resp.Code, "Not error")245 Contains(t, "Access denied", resp.Body.String(), "Wrong error reported")246 IsTrue(t, simfu.DeleteCalled, "Delete was still called on the Sim fileupdater")247}...

Full Screen

Full Screen

networkparser_test.go

Source:networkparser_test.go Github

copy

Full Screen

1package sim2import "testing"3func TestParseDelimAgents(t *testing.T) {4 data := []string{5 "Header row is always skipped |check_this_is_not_an_Id||",6 "Strips ws around Id leaves ws in Id| id _ 1 | | ",7 "Should be ignored|||",8 "Strips ws around Id| my_id ||",9 "Should also be ignored| ||",10 "Pulls entire Id without ws|1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-+={}[]()!£$%^&*@~#<>/?\\||",11 "Should also be ignored|",12 "Regular Id|Some_id7|",13 }14 po := ParseOptions{15 Delimiter: "|",16 Identifier: 1,17 Parent: -1,18 }19 rm, err := po.ParseDelim(data)20 AssertSuccess(t, err)21 agents := rm.Agents()22 AreEqual(t, 4, len(agents), "Wrong number of agents parsed from source data")23 AreEqual(t, "id _ 1", agents[0].Identifier(), "Wrong first agent Id")24 AreEqual(t, "my_id", agents[1].Identifier(), "Wrong first agent Id")25 AreEqual(t, "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-+={}[]()!£$%^&*@~#<>/?\\", agents[2].Identifier(), "Wrong first agent Id")26 AreEqual(t, "Some_id7", agents[3].Identifier(), "Wrong first agent Id")27}28func TestParseDelimLinks(t *testing.T) {29 data := []string{30 "Header row is always skipped |check_this_is_not_an_Id||",31 "Strips ws around Id leaves ws in Id| id _ 1 | | ",32 "Should be ignored|||",33 "Strips ws around Id| my_id ||id _ 1",34 "Blank lines are ignored",35 "Should also be ignored| ||",36 "Pulls entire Id without ws|1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-+={}[]()!£$%^&*@~#<>/?\\",37 "Should also be ignored|",38 "Regular Id|Some_id7||my_id|",39 "Repeated Agent Id is ignored|Some_id7||id _ 1|",40 "Another Agent child of my_id|NewId18 || my_id ",41 "Ignores a link to itself|Id69 || Id69 ",42 "Child of really long Id|NewId35 || 1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-+={}[]()!£$%^&*@~#<>/?\\",43 }44 po := ParseOptions{45 Delimiter: "|",46 Identifier: 1,47 Parent: 3,48 }49 rm, err := po.ParseDelim(data)50 AssertSuccess(t, err)51 links := rm.Links()52 AreEqual(t, 4, len(links), "Wrong number of links parsed from source data")53 for _, link := range links {54 switch link.Agent2ID {55 case "my_id":56 AreEqual(t, "id _ 1", link.Agent1ID, "Wrong parent for Agent 'my_id'")57 case "Some_id7":58 AreEqual(t, "my_id", link.Agent1ID, "Wrong parent for Agent 'Some_id7'")59 case "NewId18":60 AreEqual(t, "my_id", link.Agent1ID, "Wrong parent for Agent 'NewId18'")61 case "NewId35":62 AreEqual(t, "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-+={}[]()!£$%^&*@~#<>/?\\", link.Agent1ID, "Wrong parent for Agent 'NewId35'")63 }64 }65}66func TestParseDelimLinksThrowsErrorWhenLinkTargetDoesntExist(t *testing.T) {67 data := []string{68 "Header row is always skipped |check_this_is_not_an_Id||",69 "Strips ws around Id leaves ws in Id| id _ 1 | | ",70 "Should be ignored|||",71 "Strips ws around Id| my_id ||id _ 1",72 "Blank lines are ignored",73 "Parent doesn't exist!|Some_id7||Id615|",74 "Another Agent child of my_id|NewId18 || my_id ",75 "Ignores a link to itself|Id69 || Id69 ",76 }77 po := ParseOptions{78 Delimiter: "|",79 Identifier: 1,80 Parent: 3,81 }82 _, err := po.ParseDelim(data)83 IsFalse(t, err == nil, "Expecting an error to be thrown")84}85func TestParseDelimCsv(t *testing.T) {86 data := []string{87 "Header row is always skipped ,check_this_is_not_an_Id,,",88 "Should be ignored|||",89 "",90 "Strips ws around Id, my_id",91 "Blank lines are ignored",92 }93 po := ParseOptions{94 Delimiter: ",",95 Identifier: 1,96 Parent: 3,97 }98 rm, err := po.ParseDelim(data)99 AssertSuccess(t, err)100 agents := rm.Agents()101 AreEqual(t, 1, len(agents), "Wrong number of agents parsed from source data")102 AreEqual(t, "my_id", agents[0].Identifier(), "Wrong first agent Id")103}104func TestParseDelimTsv(t *testing.T) {105 data := []string{106 "Header row is always skipped check_this_is_not_an_Id ",107 "Should be ignored|||",108 "",109 "Strips ws around Id my_id ",110 "Blank lines are ignored",111 }112 po := ParseOptions{113 Delimiter: "\t",114 Identifier: 1,115 Parent: 3,116 }117 rm, err := po.ParseDelim(data)118 AssertSuccess(t, err)119 agents := rm.Agents()120 AreEqual(t, 1, len(agents), "Wrong number of agents parsed from source data")121 AreEqual(t, "my_id", agents[0].Identifier(), "Wrong first agent Id")122}123func TestParseDelimOnlyIncludesRowsWithOtherMatchingColumn(t *testing.T) {124 data := []string{125 "Header row is always skipped |check_this_is_not_an_Id||Include",126 "Strips ws around Id leaves ws in Id| id _ 1 | | Include ",127 "Should be ignored| id_2 ||",128 "Should be ignored| id_3",129 "Blank lines are ignored",130 "Should be included|id_4| |Include|",131 }132 po := ParseOptions{133 Delimiter: "|",134 Identifier: 1,135 Regex: map[string]string{136 "3": `\S+`,137 },138 }139 rm, err := po.ParseDelim(data)140 AssertSuccess(t, err)141 agents := rm.Agents()142 AreEqual(t, 2, len(agents), "Wrong number of agents parsed from source data")143 AreEqual(t, "id _ 1", agents[0].Identifier(), "Wrong first agent Id")144 AreEqual(t, "id_4", agents[1].Identifier(), "Wrong second agent Id")145}...

Full Screen

Full Screen

areEqual

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println(is.areEqual(1, 2))4}5import "fmt"6func main() {7 fmt.Println(is.areEqual(1, 2))8}9type is struct {10}11func (is) areEqual(x, y int) bool {12}13import "testing"14func TestAreEqual(t *testing.T) {15 if !is.areEqual(1, 1) {16 t.Error("1 is not equal to 1")17 }18}19import "testing"20func TestAreEqual(t *testing.T) {21 if !is.areEqual(1, 1) {22 t.Error("1 is not equal to 1")23 }24}25import "testing"26func TestAreEqual(t *testing.T) {27 if !is.areEqual(1, 1) {28 t.Error("1 is not equal to 1")29 }30}31import "testing"32func BenchmarkAreEqual(b *testing.B) {33 for i := 0; i < b.N; i++ {34 is.areEqual(1, 1)35 }36}37import "testing"38func BenchmarkAreEqual(b *testing.B) {39 for i := 0; i < b.N; i++ {40 is.areEqual(1, 1)41 }42}43import "testing"44func BenchmarkAreEqual(b *testing.B) {45 for i := 0; i < b.N; i++ {46 is.areEqual(1, 1)47 }48}

Full Screen

Full Screen

areEqual

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println(is.areEqual(2, 2))4}5import "fmt"6func main() {7 fmt.Println(is.areEqual(2, 2))8}9import "fmt"10func main() {11 fmt.Println(is.areEqual(2, 2))12}13import "fmt"14func main() {15 fmt.Println(is.areEqual(2, 2))16}17import "fmt"18func main() {19 fmt.Println(is.areEqual(2, 2))20}21import "fmt"22func main() {23 fmt.Println(is.areEqual(2, 2))24}25import "fmt"26func main() {27 fmt.Println(is.areEqual(2, 2))28}29import "fmt"30func main() {31 fmt.Println(is.areEqual(2, 2))32}33import "fmt"34func main() {35 fmt.Println(is.areEqual(2, 2))36}37import "fmt"38func main() {39 fmt.Println(is.areEqual(2, 2))40}41import "fmt"42func main() {43 fmt.Println(is.areEqual(2, 2))44}45import "fmt"46func main() {47 fmt.Println(is.areEqual(2, 2))48}

Full Screen

Full Screen

areEqual

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 var a = is{1,2}4 var b = is{1,2}5 fmt.Println(a.areEqual(b))6}7import "fmt"8func main() {9 var a = is{1,2}10 var b = is{1,2}11 fmt.Println(a.areEqual(b))12}13import "fmt"14func main() {15 var a = is{1,2}16 var b = is{1,2}17 fmt.Println(a.areEqual(b))18}19import "fmt"20func main() {21 var a = is{1,2}22 var b = is{1,2}23 fmt.Println(a.areEqual(b))24}25import "fmt"26func main() {27 var a = is{1,2}28 var b = is{1,2}29 fmt.Println(a.areEqual(b))30}31import "fmt"32func main() {33 var a = is{1,2}34 var b = is{1,2}35 fmt.Println(a.areEqual(b))36}37import "fmt"38func main() {39 var a = is{1,2}40 var b = is{1,2}41 fmt.Println(a.areEqual(b))42}43import "fmt"44func main() {45 var a = is{1,2}46 var b = is{1,2}47 fmt.Println(a.areEqual(b))48}49import "fmt"50func main() {51 var a = is{1,2}52 var b = is{1,2}

Full Screen

Full Screen

areEqual

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3fmt.Printf("Enter two numbers: ")4fmt.Scanf("%d %d", &a, &b)5result := is.areEqual(a, b)6if result {7fmt.Printf("%d and %d are equal", a, b)8} else {9fmt.Printf("%d and %d are not equal", a, b)10}11}12import "fmt"13func main() {14fmt.Printf("Enter two numbers: ")15fmt.Scanf("%d %d", &a, &b)16result := is.areEqual(a, b)17if result {18fmt.Printf("%d and %d are equal", a, b)19} else {20fmt.Printf("%d and %d are not equal", a, b)21}22}23import "fmt"24func main() {25fmt.Printf("Enter two numbers: ")26fmt.Scanf("%d %d", &a, &b)27result := is.areEqual(a, b)28if result {29fmt.Printf("%d and %d are equal", a, b)30} else {31fmt.Printf("%d and %d are not equal", a, b)32}33}34import "fmt"35func main() {36fmt.Printf("Enter two numbers: ")37fmt.Scanf("%d %d", &a, &b)38result := is.areEqual(a, b)39if result {40fmt.Printf("%d and %d are equal", a, b)41} else {42fmt.Printf("%d and %d are not equal", a, b)43}44}45import "fmt"46func main() {47fmt.Printf("Enter two numbers: ")48fmt.Scanf("%d %d", &a, &b)49result := is.areEqual(a, b)50if result {51fmt.Printf("%d and %d are equal", a, b)52} else {53fmt.Printf("%d and %d are not equal", a, b)54}55}

Full Screen

Full Screen

areEqual

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 result = is.areEqual(a, b)4 fmt.Println(result)5 result = is.areEqual(c, d)6 fmt.Println(result)7}

Full Screen

Full Screen

areEqual

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4}5import (6func main() {7 fmt.Println("Hello, playground")8}9import (10func main() {11 fmt.Println("Hello, playground")12}13import (14func main() {15 fmt.Println("Hello, playground")16}17import (18func main() {19 fmt.Println("Hello, playground")20}21import (22func main() {23 fmt.Println("Hello, playground")24}25import (26func main() {27 fmt.Println("Hello, playground")28}29import (30func main() {31 fmt.Println("Hello, playground")32}33import (34func main() {35 fmt.Println("Hello, playground")36}37import (38func main() {39 fmt.Println("Hello

Full Screen

Full Screen

areEqual

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println(a, b, c)4 fmt.Println(a == b)5 fmt.Println(a == c)6 fmt.Println(a == b, a == c)7}8import "fmt"9func main() {10 fmt.Println(a, b, c)11 fmt.Println(is.areEqual(a, b))12 fmt.Println(is.areEqual(a, c))13 fmt.Println(is.areEqual(a, b), is.areEqual(a, c))14}15import "fmt"16func main() {17 fmt.Println(a, b, c)18 fmt.Println(is.areEqual(a, b))19 fmt.Println(is.areEqual(a, c))20 fmt.Println(is.areEqual(a, b), is.areEqual(a, c))21}22import "fmt"23func main() {24 fmt.Println(a, b, c)25 fmt.Println(is.areEqual(a, b))26 fmt.Println(is.areEqual(a, c))27 fmt.Println(is.areEqual(a, b), is.areEqual(a, c))28}29import "fmt"30func main() {31 fmt.Println(a, b, c)32 fmt.Println(is.are

Full Screen

Full Screen

areEqual

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 i1 := is{5}4 i2 := is{5}5 fmt.Println(i1.areEqual(i2))6}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful