Back to home page

EIC code displayed by LXR

 
 

    


Warning, /firebird/firebird-ng/src/lib-root-geometry/root-geo-attribute-bits.spec.ts is written in an unsupported language. File is not indexed.

0001 /**
0002  * @date Created on July 10, 2024
0003  * @author Dmitry Romanov
0004  *
0005  * @license This file is part of the Firebird display, which is released under a license agreement
0006  * available in the LICENSE file located in the root directory of this project source tree. This
0007  * file is subject to that license and is intended to be used in accordance with it.
0008  *
0009  * @summary Unit test for GeoAttBits enum and functions for its manipulation.
0010  */
0011 
0012 import { GeoAttBits, setGeoBit, testGeoBit, toggleGeoBit } from "./root-geo-attribute-bits";
0013 
0014 describe('GeoBits Functions', () => {
0015     let volume: any;
0016 
0017     beforeEach(() => {
0018         volume = { fGeoAtt: 0 }; // Initialize volume with fGeoAtt set to 0
0019     });
0020 
0021     describe('testGeoBit', () => {
0022         it('should return false if fGeoAtt is undefined', () => {
0023             volume.fGeoAtt = undefined;
0024             expect(testGeoBit(volume, GeoAttBits.kVisThis)).toBe(false);
0025         });
0026 
0027         it('should return false if the bit is not set', () => {
0028             volume.fGeoAtt = 0;
0029             expect(testGeoBit(volume, GeoAttBits.kVisThis)).toBe(false);
0030         });
0031 
0032         it('should return true if the bit is set', () => {
0033             volume.fGeoAtt = GeoAttBits.kVisThis;
0034             expect(testGeoBit(volume, GeoAttBits.kVisThis)).toBe(true);
0035         });
0036     });
0037 
0038     describe('setGeoBit', () => {
0039         it('should set the bit if value is 1', () => {
0040             setGeoBit(volume, GeoAttBits.kVisThis, 1);
0041             expect(testGeoBit(volume, GeoAttBits.kVisThis)).toBe(true);
0042         });
0043 
0044         it('should clear the bit if value is 0', () => {
0045             volume.fGeoAtt = GeoAttBits.kVisThis;
0046             setGeoBit(volume, GeoAttBits.kVisThis, 0);
0047             expect(testGeoBit(volume, GeoAttBits.kVisThis)).toBe(false);
0048         });
0049 
0050         it('should not modify fGeoAtt if it is undefined', () => {
0051             volume.fGeoAtt = undefined;
0052             setGeoBit(volume, GeoAttBits.kVisThis, 1);
0053             expect(volume.fGeoAtt).toBeUndefined();
0054         });
0055     });
0056 
0057     describe('toggleGeoBit', () => {
0058         it('should toggle the bit from 0 to 1', () => {
0059             toggleGeoBit(volume, GeoAttBits.kVisThis);
0060             expect(testGeoBit(volume, GeoAttBits.kVisThis)).toBe(true);
0061         });
0062 
0063         it('should toggle the bit from 1 to 0', () => {
0064             volume.fGeoAtt = GeoAttBits.kVisThis;
0065             toggleGeoBit(volume, GeoAttBits.kVisThis);
0066             expect(testGeoBit(volume, GeoAttBits.kVisThis)).toBe(false);
0067         });
0068 
0069         it('should not modify fGeoAtt if it is undefined', () => {
0070             volume.fGeoAtt = undefined;
0071             toggleGeoBit(volume, GeoAttBits.kVisThis);
0072             expect(volume.fGeoAtt).toBeUndefined();
0073         });
0074     });
0075 });