Example16.java
Model: Codex (codedavinci002); Similarity Score: 0.80
Generate
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
// First, initialize the Angular testing environment.
// Then we find all the tests.
// And load the modules.
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
Source
/*
* Copyright 2018-present
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
Example17.py
Model: Codex (codedavinci002); Similarity Score: 0.80
Generate
def run_virsh_resume(test, params, env):
"""
Test command: virsh resume.
The command can Resume a domain.
1.Prepare test environment.
2.When the libvirtd == "off", stop the libvirtd service.
3.Perform virsh resume operation.
4.Recover test environment.
5.Confirm the test result.
"""
vm_name = params.get("main_vm")
vm = env.get_vm(vm_name)
vm_ref = params.get("resume_vm_ref")
status_error = params.get("status_error", "no")
libvirtd = params.get("libvirtd", "on")
extra = params.get("resume_extra", "")
if vm_ref == "id":
vm_ref = vm.get_id()
elif vm_ref == "hex_id":
vm_ref = hex(vm.get_id())
elif vm_ref == "name":
vm_ref = "%s %s" % (vm_name, extra
Source
def run_virsh_resume(test, params, env):
"""
Test command: virsh resume.
1) Start vm, Prepare options such as id, uuid
2) Prepare vm state for test, default is paused.
3) Prepare other environment
4) Run command, get result.
5) Check result.
"""
vm_name = params.get("main_vm")
vm = env.get_vm(vm_name)
vm.verify_alive()
# Get parameters
vm_ref = params.get("resume_vm_ref", "domname")
vm_state = params.get("resume_vm_state", "paused")
option_suffix = params.get("resume_option_suffix")
status_error = params.get("status_error", "no")
domid = vm.get_id()
domuuid = vm.get_uuid()
# Prepare vm state
if vm_state == "paused":
vm.pause()
elif vm_state == "shutoff":
vm.destroy()
# Prepare options
if vm_ref == "domname":
vm_ref = vm_name
elif vm_ref == "domid":
vm_ref = domid
elif vm_ref == "domuuid":
vm_ref = domuuid
Example18.cpp
Model: ChatGPT; Similarity Score: 0.87
Generate
void printGraph(vector<int> adj[], int V) {
for (int i = 0; i < V; i++) {
cout << "Adjacency list of vertex " << i << ": ";
for (int j = 0; j < adj[i].size(); j++) {
cout << adj[i][j] << " ";
}
cout << endl;
}
}
Source
void printGraph(vector<int> adj[], int V)
{
for(int i =0; i < V; i++)
{
cout << i;
for(int j =0; j < adj[i].size(); j++)
cout << "-> "<<adj[i][j];
cout <<endl;
}
}