github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/shell/hintsummary/class_test.go (about)

     1  package hintsummary
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/lmorg/murex/test/count"
     7  )
     8  
     9  // TestHintSummary tests the HintSummary structure
    10  func TestHintSummary(t *testing.T) {
    11  	count.Tests(t, 6)
    12  
    13  	summary := New()
    14  
    15  	summary.Set("cmd1", "sum1")
    16  	if summary.Get("cmd1") != "sum1" {
    17  		t.Error("Get (1) returns the wrong string")
    18  	}
    19  
    20  	summary.Set("cmd2", "sum2")
    21  	if summary.Get("cmd2") != "sum2" {
    22  		t.Error("Get (2) returns the wrong string")
    23  	}
    24  
    25  	summary.Set("cmd3", "sum3")
    26  	if summary.Get("cmd3") != "sum3" {
    27  		t.Error("Get (3) returns the wrong string")
    28  	}
    29  
    30  	if len(summary.Dump()) != 3 {
    31  		t.Error("length of summary map is incorrect")
    32  	}
    33  
    34  	err := summary.Delete("cmd1")
    35  	if err != nil {
    36  		t.Error(err.Error())
    37  	}
    38  
    39  	if len(summary.Dump()) != 2 {
    40  		t.Error("length of summary map is incorrect")
    41  	}
    42  }