March 2019
Intermediate to advanced
336 pages
9h 9m
English
Here, we have written a unit test for the social graph method. The code is as follows:
///main package has examples shown// in Go Data Structures and algorithms bookpackage main// importing testing packageimport ( "fmt" "testing")// NewSocialGraph test methodfunc TestNewSocialGraph(test *testing.T) { var socialGraph *SocialGraph socialGraph = NewSocialGraph(1) if socialGraph == nil { test.Errorf("error in creating a social Graph") }}
Run the following command to execute the preceding code snippet:
go test -run NewSocialGraph -v
The output is as follows:

In the next section, a social network representation will be implemented with code ...
Read now
Unlock full access