github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/runtime/runtimecontextmanager_noquotas_test.go (about)

     1  //go:build noquotas
     2  // +build noquotas
     3  
     4  package runtime
     5  
     6  import (
     7  	"testing"
     8  )
     9  
    10  func Test_runtimeContextManager_RuntimeContext(t *testing.T) {
    11  	var m runtimeContextManager
    12  	if m.HardLimits() != (RuntimeResources{}) {
    13  		t.Fail()
    14  	}
    15  	if m.SoftLimits() != (RuntimeResources{}) {
    16  		t.Fail()
    17  	}
    18  	if m.UsedResources() != (RuntimeResources{}) {
    19  		t.Fail()
    20  	}
    21  	if m.Status() != StatusLive {
    22  		t.Fail()
    23  	}
    24  	if m.RequiredFlags() != 0 {
    25  		t.Fail()
    26  	}
    27  	if m.CheckRequiredFlags(0) != nil {
    28  		t.Fail()
    29  	}
    30  	if m.Parent() != nil {
    31  		t.Fail()
    32  	}
    33  	if m.Due() {
    34  		t.Fail()
    35  	}
    36  	if m.RuntimeContext() != &m {
    37  		t.Fail()
    38  	}
    39  	m2 := m
    40  	m2.SetStopLevel(HardStop | SoftStop)
    41  	if m != m2 {
    42  		t.Fail()
    43  	}
    44  }
    45  
    46  func Test_runtimeContextManager_TerminateContext(t *testing.T) {
    47  	defer func() {
    48  		if r := recover(); r == nil {
    49  			t.Error("No panic")
    50  		}
    51  	}()
    52  	var m runtimeContextManager
    53  	m.TerminateContext("foo")
    54  }
    55  
    56  func Test_runtimeContextManager_UnusedResources(t *testing.T) {
    57  	var m runtimeContextManager
    58  	if m.UnusedMem() != 0 {
    59  		t.Fail()
    60  	}
    61  	if m.UnusedCPU() != 0 {
    62  		t.Fail()
    63  	}
    64  }
    65  
    66  func Test_runtimeContextManager_ResetQuota(t *testing.T) {
    67  	var m runtimeContextManager
    68  	var m1 = m
    69  	m.ResetQuota()
    70  	if m != m1 {
    71  		t.Fail()
    72  	}
    73  }