<commit_before>/*
 * error.js
 */


const gi = require('../lib/')
const GLib = gi.require('GLib', '2.0')
const Gst = gi.require('Gst', '1.0')
const common = require('./__common__.js')

Gst.init()

const QUARK_STRING = 'example'
const CUSTOM_QUARK = GLib.quarkFromString(QUARK_STRING)
const ERROR_MESSAGE = 'ERROR_MESSAGE'
const ERROR_CODE = 42
const DEBUG_STRING = 'debug string'

common.describe('GError', () => {
  common.it('should be returned', () => {
    common.assert(GLib.Error !== undefined)
    const err0 = GLib.Error.newLiteral(CUSTOM_QUARK, ERROR_CODE, ERROR_MESSAGE)
    common.assert(err0.code === ERROR_CODE && err0.message === ERROR_MESSAGE)

    const msg = Gst.Message.newError(null, err0, DEBUG_STRING)
    const [err1, debugString] = msg.parseError();
    common.assert(err1.code === ERROR_CODE && err1.message === ERROR_MESSAGE)
    common.assert(debugString === DEBUG_STRING)
    common.assert(GLib.quarkToString(err1.domain) === QUARK_STRING)
  })
})<commit_msg>Rewrite error test<commit_after>/*
 * error.js
 */


const gi = require('../lib/')
const GLib = gi.require('GLib', '2.0')
const Gst = gi.require('Gst', '1.0')
const { describe, it, assert } = require('./__common__.js')

Gst.init()

const QUARK_STRING = 'example'
const CUSTOM_QUARK = GLib.quarkFromString(QUARK_STRING)
const ERROR_MESSAGE = 'ERROR_MESSAGE'
const ERROR_CODE = 42
const DEBUG_STRING = 'debug string'

describe('GError', () => {
  it('should be returned', () => {
    assert(GLib.Error !== undefined, 'Error is not available')
    const err0 = GLib.Error.newLiteral(CUSTOM_QUARK, ERROR_CODE, ERROR_MESSAGE)
    assert(err0.code === ERROR_CODE && err0.message === ERROR_MESSAGE, 'code or message is not accessible')

    const msg = Gst.Message.newError(null, err0, DEBUG_STRING)
    const [err1, debugString] = msg.parseError();
    assert(err1.code === ERROR_CODE && err1.message === ERROR_MESSAGE, 'code or message is not equal')
    assert(debugString === DEBUG_STRING, 'debug string is not returned')
    assert(err1.domain === CUSTOM_QUARK && GLib.quarkToString(err1.domain) === QUARK_STRING, 'domain does not match')
  })
})
{'fraction_non_alphanumeric': 0.1568075117370892, 'fraction_numerical': 0.013615023474178404, 'mean_word_length': 4.637566137566138, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7507519', 'n_tokens_mistral': 728, 'n_tokens_neox': 705, 'n_words': 161}